mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 04:03:34 -08:00
Added livewire the login screen
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
576e605f73
commit
704eb728bc
67
app/Http/Livewire/LoginForm.php
Normal file
67
app/Http/Livewire/LoginForm.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class LoginForm extends Component
|
||||
{
|
||||
public $username = '';
|
||||
public $password = '';
|
||||
public $can_submit = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set the validation rules for login
|
||||
*
|
||||
* @author A. Ginaotto <snipe@snipe.net>
|
||||
* @version v6.0
|
||||
* @return Array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'username' => 'required|string|max:255',
|
||||
'password' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the validation
|
||||
*
|
||||
* @author A. Ginaotto <snipe@snipe.net>
|
||||
* @version v6.0
|
||||
*/
|
||||
public function updated($fields)
|
||||
{
|
||||
$this->validateOnly($fields);
|
||||
|
||||
if (!is_null($fields) && !empty($fields)) {
|
||||
$this->can_submit = true;
|
||||
} else {
|
||||
$this->can_submit = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually do the login thing
|
||||
*
|
||||
* @todo fix missing LDAP stuff maybe?
|
||||
* @author A. Ginaotto <snipe@snipe.net>
|
||||
* @version v6.0
|
||||
*/
|
||||
public function submitForm()
|
||||
{
|
||||
|
||||
$validatedData = $this->validate();
|
||||
|
||||
if (\Auth::attempt(array('username' => $this->username, 'password' => $this->password))){
|
||||
redirect()->route('dashboard');
|
||||
} else {
|
||||
session()->flash('error', 'email and password are wrong.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -4,90 +4,6 @@
|
|||
{{-- Page content --}}
|
||||
@section('content')
|
||||
|
||||
<form role="form" action="{{ url('/login') }}" method="POST" autocomplete="false">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
|
||||
|
||||
<!-- this is a hack to prevent Chrome from trying to autocomplete fields -->
|
||||
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" aria-hidden="true">
|
||||
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" aria-hidden="true">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
|
||||
<div class="box login-box">
|
||||
<div class="box-header with-border">
|
||||
<h1 class="box-title"> {{ trans('auth/general.login_prompt') }}</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="login-box-body">
|
||||
<div class="row">
|
||||
|
||||
@if ($snipeSettings->login_note)
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
{!! Parsedown::instance()->text(e($snipeSettings->login_note)) !!}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Notifications -->
|
||||
@include('notifications')
|
||||
|
||||
<div class="col-md-12">
|
||||
<!-- CSRF Token -->
|
||||
|
||||
|
||||
<fieldset>
|
||||
|
||||
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
|
||||
<label for="username"><i class="fa fa-user" aria-hidden="true"></i> {{ trans('admin/users/table.username') }}</label>
|
||||
<input class="form-control" placeholder="{{ trans('admin/users/table.username') }}" name="username" type="text" id="username" autocomplete="off" autofocus>
|
||||
{!! $errors->first('username', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password"><i class="fa fa-key" aria-hidden="true"></i> {{ trans('admin/users/table.password') }}</label>
|
||||
<input class="form-control" placeholder="{{ trans('admin/users/table.password') }}" name="password" type="password" id="password" autocomplete="off">
|
||||
{!! $errors->first('password', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label style="margin-left: -20px;">
|
||||
<input name="remember" type="checkbox" value="1" class="minimal"> {{ trans('auth/general.remember_me') }}
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div> <!-- end col-md-12 -->
|
||||
|
||||
</div> <!-- end row -->
|
||||
|
||||
@if ($snipeSettings->saml_enabled)
|
||||
<div class="row ">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button class="btn btn-lg btn-primary btn-block">{{ trans('auth/general.login') }}</button>
|
||||
</div>
|
||||
<div class="col-md-12 col-sm-12 col-xs-12 text-right" style="padding-top: 10px;">
|
||||
@if ($snipeSettings->custom_forgot_pass_url)
|
||||
<a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a>
|
||||
@else
|
||||
<a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a>
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
</div> <!-- end login box -->
|
||||
|
||||
</div> <!-- col-md-4 -->
|
||||
|
||||
</div> <!-- end row -->
|
||||
</div> <!-- end container -->
|
||||
</form>
|
||||
@livewire('login-form')
|
||||
|
||||
@stop
|
||||
|
|
105
resources/views/livewire/login-form.blade.php
Normal file
105
resources/views/livewire/login-form.blade.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<div>
|
||||
<form role="form" method="POST" action="{{ route('login') }}" autocomplete="false" wire:submit.prevent="submitForm">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
|
||||
|
||||
<!-- this is a hack to prevent Chrome from trying to autocomplete fields -->
|
||||
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" aria-hidden="true">
|
||||
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" aria-hidden="true">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
|
||||
<div class="box login-box">
|
||||
<div class="box-header with-border">
|
||||
<h1 class="box-title"> {{ trans('auth/general.login_prompt') }}</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="login-box-body">
|
||||
<div class="row">
|
||||
|
||||
@if ($snipeSettings->login_note)
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
{!! Parsedown::instance()->text(e($snipeSettings->login_note)) !!}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Notifications -->
|
||||
@include('notifications')
|
||||
|
||||
<div class="col-md-12">
|
||||
<!-- CSRF Token -->
|
||||
|
||||
<fieldset>
|
||||
|
||||
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
|
||||
<label for="username">
|
||||
<i class="fa fa-user" aria-hidden="true"></i>
|
||||
{{ trans('admin/users/table.username') }}
|
||||
</label>
|
||||
<input class="form-control" placeholder="{{ trans('admin/users/table.username') }}" name="username" type="text" id="username" autocomplete="off" wire:model="username" wire:model.lazy="username" autofocus>
|
||||
@error('username')
|
||||
<span class="alert-msg">
|
||||
{{ $message }}
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password">
|
||||
<i class="fa fa-key" aria-hidden="true"></i>
|
||||
{{ trans('admin/users/table.password') }}
|
||||
</label>
|
||||
<input class="form-control" placeholder="{{ trans('admin/users/table.password') }}" name="password" type="password" id="password" wire:model="password" wire:model.lazy="password" autocomplete="off">
|
||||
@error('password')
|
||||
<span class="alert-msg">
|
||||
{{ $message }}
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label style="margin-left: -20px;">
|
||||
<input name="remember" type="checkbox" value="1" class="minimal"> {{ trans('auth/general.remember_me') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div> <!-- end col-md-12 -->
|
||||
|
||||
</div> <!-- end row -->
|
||||
|
||||
@if ($snipeSettings->saml_enabled)
|
||||
<div class="row">
|
||||
<div class="text-right col-md-12">
|
||||
<a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit"{{ $can_submit ? '' : ' disabled' }}>
|
||||
<i wire:loading wire:target='submitForm' class="fa fa-spin fa-spinner"></i> {{ trans('auth/general.login') }}</button>
|
||||
</div>
|
||||
<div class="text-right col-md-12 col-sm-12 col-xs-12" style="padding-top: 10px;">
|
||||
@if ($snipeSettings->custom_forgot_pass_url)
|
||||
<a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a>
|
||||
@else
|
||||
<a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a>
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
</div> <!-- end login box -->
|
||||
|
||||
</div> <!-- col-md-4 -->
|
||||
|
||||
</div> <!-- end row -->
|
||||
</div> <!-- end container -->
|
||||
</form>
|
||||
|
||||
</div>
|
Loading…
Reference in a new issue