i have a function which sync api, i have to manually trigger the function from the front end by passing some parameters .
Can someone help me with script or a way to automatically sync the function after some specific time interval.
Code for frontend is below
<form
role="form"
method="POST"
action="{{ url('/admin/apisync/show') }}">
{{ csrf_field() }}
#if( ! $apis->isEmpty() )
<fieldset class="scheduler-border">
<div class="form-group{{ $errors->has('profit_percentage') ? ' has-
error' : '' }}">
<input type="text"
class="form-control"
data-validation="number"
placeholder="Profit Percentage"
data-validation-allowing="float"
id="profit_percentage"
value="{{ old('profit_percentage') }}"
name="profit_percentage">
#if ($errors->has('profit_percentage'))
<span class="help-block">
<strong>{{ $errors->first('profit_percentage') }}
</strong>
</span>
#endif
</div>
<div class="form-group">
<label for="sync_action" class="control-label">Sync Actions</label>
<label class="checkbox-inline">
<input type="checkbox"
style="margin: 0; margin-left: -20px"
name="sync_action[]"
checked
value="remove"> Remove
</label> <span class="fas fa-info-circle" data-
toggle="popover" data-trigger="hover" data-content="This will remove packages which exist
at your panel but have been removed at host"></span>
</div>
<div class="form-group" style="float:right">
<button type="submit" id="btn-proceed" class="btn btn-primary">Sync
Packages</button>
</div>
</fieldset>
#else
<span class="help-block">
<strong>No API is configured. Please update your API
configurations.</strong>
</span>
#endif
</form>
Related
In my code, the user enter details and it lets in login.
Login code:
<form class="mt-3" action="{{ secure_url('login') }}" id="login_form" method="POST" enctype="multipart/form-data">
{{csrf_field()}}
<div class="">
</div>
<br>
<h4 class="font-weight-bolder">Login to Your Account</h4>
<br>
#if ($errors->has('email'))
<div class="cust-danger mb-4">
<span class="invalid-feedback d-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
</div>
#endif
<input class="form-control mb-3" placeholder="Email address" value="{{old('email')}}" type="email" name="email"
required />
<input class="form-control mb-3" placeholder="Password" type="password" name="password" required />
<button class="btn btn-primary boxShadow " type="submit"> Login</button>
<a class="btn btn-link" style="color:#0676BD" href="{{route('guest_home')}}">Home</a>
<a class="btn btn-link" style="color:#0676BD" href="{{ route('password.request') }}">Forgot Pasword?</a>
</form>
This is the code for 2 factor authentication:
#if(Auth::user()->user_account_type === 1)
#extends('dashboards.user.user_master')
#section('dashboard_master_content')
#else
#extends('dashboards.solicitor.solicitor_master')
#section('child')
#endif
<nav class="ml-2 mr-2" aria-label="breadcrumb">
<ol class="breadcrumb bg-white m-0 p-2 rounded-lg">
#if(Auth::user()->user_account_type === 1)
<li class="breadcrumb-item">User Home</li>
#else
<li class="breadcrumb-item">Home</li>
#endif
<li class="breadcrumb-item active" aria-current="page">Security Management</li>
</ol>
</nav>
<div class="col-lg-12 p-2">
#include('common.error_display')
</div>
<button class=" ml-2 btn btn-sm btn-secondary boxShadow" onclick="location.href='{{route('user_dashboard')}}'">Go
back</button>
<div class="row m-1">
<div class="col-lg-6 p-3 rounded-lg m-2" style="background-color: #f7f7f7">
<h5 class="font-weight-bolder pb-3 text-center">Two Factor Authentication</h5>
#include('common.elements.custom_hr')
<div class="panel panel-default">
<div class="panel-heading"><strong>Two Factor Authentication</strong></div>
<div class="panel-body">
<p>Two factor authentication (2FA) strengthens access security by requiring two methods (also
referred to as factors) to verify your identity. Two factor authentication protects against
phishing, social engineering and password brute force attacks and secures your logins from
attackers exploiting weak or stolen credentials.</p>
<br />
<p>To Enable Two Factor Authentication on your Account, you need to do following steps</p>
<strong>
<ol>
<li>Click on Generate Secret Button , To Generate a Unique secret QR code for your
profile
</li>
<li>Verify the OTP from Google Authenticator Mobile App</li>
</ol>
</strong>
<br />
#if (session('error'))
<div class="alert alert-danger">
{{ session('error') }}
</div>
#endif
#if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
#endif
#if(!count((array)$data['user']->passwordSecurity))
<form class="form-horizontal" method="POST" action="{{ route('generate2faSecret') }}"
onsubmit="toggle_animation(true,'Generating Secret Key')">
{{ csrf_field() }}
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary boxShadow">
Generate Secret Key to Enable 2FA
</button>
</div>
</div>
</form>
#elseif(!$data['user']->passwordSecurity->google2fa_enable)
<strong>1. Scan this barcode with your Google Authenticator App:</strong><br />
<img src="{{$data['google2fa_url'] }}" alt="">
<br /><br />
<strong>2.Enter the pin the code to Enable 2FA</strong><br /><br />
<form class="form-horizontal" method="POST" action="{{ route('enable2fa') }}"
onsubmit="toggle_animation(true,'Enabling 2-Factor Authentication')">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('verify-code') ? ' has-error' : '' }}">
<label for="verify-code" class="col-md-4 control-label">Authenticator Code</label>
<div class="col-md-6">
<input id="verify-code" type="password" class="form-control" name="verify-code" required>
#if ($errors->has('verify-code'))
<span class="help-block">
<strong>{{ $errors->first('verify-code') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary boxShadow">
Enable 2FA
</button>
</div>
</div>
</form>
#elseif($data['user']->passwordSecurity->google2fa_enable)
<div class="alert alert-success">
2FA is Currently <strong>Enabled</strong> for your account.
</div>
<p>If you are looking to disable Two Factor Authentication. Please confirm your password and
Click
Disable 2FA Button.</p>
<form class="form-horizontal" method="POST" action="{{ route('disable2fa') }}"
onsubmit="toggle_animation(true,'Disabling 2-Factor Authentication')">
<div class="form-group{{ $errors->has('current-password') ? ' has-error' : '' }}">
<label for="change-password" class="col-md-4 control-label">Current Password</label>
<div class="col-md-6">
<input id="current-password" type="password" class="form-control" name="current-password"
required>
#if ($errors->has('current-password'))
<span class="help-block">
<strong>{{ $errors->first('current-password') }}</strong>
</span>
#endif
</div>
</div>
<div class="col-md-6 col-md-offset-5">
{{ csrf_field() }}
<button type="submit" class="btn btn-primary boxShadow">Disable 2FA</button>
</div>
</form>
#endif
</form>
</div>
</div>
</div>
</div>
#endsection
After the user logs in I want it to call the code at line 78 to 95 (added the code below) where it asks to enter the 2 factor code
<strong>2.Enter the pin the code for 2FA</strong><br /><br />
<form class="form-horizontal" method="POST" action="{{ route('enable2fa') }}"
onsubmit="toggle_animation(true,'Enabling 2-Factor Authentication')">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('verify-code') ? ' has-error' : '' }}">
<label for="verify-code" class="col-md-4 control-label">Authenticator Code</label>
<div class="col-md-6">
<input id="verify-code" type="password" class="form-control" name="verify-code" required>
#if ($errors->has('verify-code'))
<span class="help-block">
<strong>{{ $errors->first('verify-code') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary boxShadow">
Submit 2FA
</button>
</div>
</div>
</form>
then it should go back to normal to the action I am using in login class for secure login to let the user login.
How can I do that?
So now the user can login. So in short = the user logs in -> goes to 2 factor class to call that form to let user enter 2 factor code -> goes to let the user login.
I am implementing authentication in my Laravel application, the register and logout routes are working perfectly fine, but the login form is not working. I'm not getting any error, but when I click the logi button it doesn't go anywhere.
Here is my login.blade.php :
#extends('layouts.app')
#section('title', 'Login')
#section('content')
<form class="form-horizontal form-material" id="loginform" method="POST" action="{{ route('login') }}>
#csrf
<h3 class="text-center m-b-20">Sign In</h3>
<div class="form-group ">
<div class="col-xs-12">
<input required="" id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" placeholder="Enter your Email" name="email" value="{{ old('email') }}" required autofocus> </div>
#if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div class="form-group">
<div class="col-xs-12">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" placeholder="Enter your Password" required>
#if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<div class="d-flex no-block align-items-center">
<div class="custom-control custom-checkbox">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
<div class="ml-auto">
<i class="fas fa-lock m-r-5"></i>{{ __('Forgot Your Password?') }}
</div>
</div>
</div>
</div>
<div class="form-group text-center">
<div class="col-xs-12 p-b-20">
<button class="btn btn-block btn-info btn-rounded" type="submit">{{ __('Login') }}</button>
</div>
</div>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
Don't have an account? <b>Sign Up</b>
</div>
</div>
</form>
#endsection
These are my login routes:
$this->get('admin/login', 'Auth\LoginController#showLoginForm')->name('login');
$this->post('admin/login', 'Auth\LoginController#login');
Does anyone know where I messed up?
You can try implementing the standard auth routing wrapped in a prefix to give you want you want:
Route::group(['prefix' => 'admin'], function () {
Auth::routes();
});
That way you do not have to worry about the route names being different from the docs :)
I have got the issue in Laravel of The page has expired due to inactivity.
Please refresh and try again. I have also check {{ csrf_field() }} and its is fine but issue is still there. I have also checked about try cache, view, route clear command but again bad luck. Can any one suggest me what is the issue.
Form Code :
<form id="loginform" class="form-vertical" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="control-group normal_text"> <h3><img src="{{ asset('img/logo.png') }}" alt="Logo" /></h3></div>
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_lg"><i class="icon-user"> </i></span>
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus placeholder="Username"/>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_ly"><i class="icon-lock"></i></span>
<input id="password" type="password" class="form-control" name="password" required placeholder="Password" />
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="form-actions">
<span class="pull-left">Lost password?</span>
<span class="pull-right"><button type="submit" class="btn btn-success">Login</button></span>
</div>
</form>
I have solved.
I have tried all steps from https://www.5balloons.info/fixed-page-expired-due-inactivity-laravel-5/ but the issue is still on there.
The main issue was my browser catch setting.
see below screenshot for more idea.
I'm following a tutorial about Authorization in laravel, but it seems it got some errors in the code like this:
"Type error: Argument 2 passed to App\Providers\AuthServiceProvider::App\Providers\{closure}() must be an instance of App\Providers\Post, instance of App\Post given, called in E:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Auth\Access\Gate.php on line 323 ◀"
I got those error code when I'm accessing http://cms.dev/posts/edit/2. here's the code that i've put on AuthServicesProfider:
public function registerPostPolicies()
{
Gate::define('create-post', function ($user) {
return $user->hasAccess(['create-post']);
});
Gate::define('update-post', function ($user, Post $post) {
return $user->hasAccess(['update-post']) or $user->id == $post->user_id;
});
Gate::define('publish-post', function ($user) {
return $user->hasAccess(['publish-post']);
});
Gate::define('see-all-drafts', function ($user) {
return $user->inRole('editor');
});
}
and here's the code for the update.blade:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Update Post</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ route('update_post', ['post' => $post->id]) }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Title</label>
<div class="col-md-6">
<input id="title" type="text" class="form-control" name="title" value="{{ old('title', $post->title) }}" required autofocus>
#if ($errors->has('title'))
<span class="help-block">
<strong>{{ $errors->first('title') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('body') ? ' has-error' : '' }}">
<label for="body" class="col-md-4 control-label">Body</label>
<div class="col-md-6">
<textarea name="body" id="body" cols="30" rows="10" class="form-control" required>{{ old('body', $post->body) }}</textarea>
#if ($errors->has('body'))
<span class="help-block">
<strong>{{ $errors->first('body') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Update
</button>
#can('publish-post')
<a href="{{ route('publish_post', ['post' => $post->id]) }}" class="btn btn-primary">
Publish
</a>
#endcan
<a href="{{ route('list_posts') }}" class="btn btn-primary">
Cancel
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
I really have no idea about how to fix it since i really don't understand about authorization in Laravel. Thanks.
You're missing a use statement for the Post class, therefore PHP assumes the gate takes the Post class from the current namespace, hence the App\Providers\Post in the error message.
Add the following in the provider class:
use App\Post;
I have this form working on Localhost but when I upload to my shared hosting they throw VerifyCsrfToken.php line 67.
Here the code:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-sign-in"></i> Login
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}">Forgot Your Password?</a>
FB Login
</div>
</div>
</form>
I added this: <meta name="csrf-token" content="{{ csrf_token() }}" /> in to my head tags, but it's not working. The token is okay, appears on the form when I inspect with Google Chrome Inspector. If someone can help on this I am really stuck here.
Check your session directory for correct permissions, it might be help.
rm -f {your_web_app}/storage/framework/sessions/*
You properly have trouble with session storage
Solution 1: Use database session driver instead of file session driver
- In .env
SESSION_DRIVER=database
- Run command
php artisan session:table
- Then
php artisan migrate
Test again
Solution 2: Continue using file session driver. Make sure you have writing permission on storage folder. Try
chmod 755 -R storage
I am using this method.
<input type="hidden" name="_token" value="{{ session()->getToken() }}">
In your view blade.