2023-07-24 20:55:26 -04:00
|
|
|
@extends('layout.base')
|
|
|
|
|
|
|
|
@section('page_content')
|
|
|
|
<div class="ui container">
|
|
|
|
<div class="ui form" id="login_form">
|
|
|
|
<div class="six wide field">
|
|
|
|
<label for="name">Nombre</label>
|
|
|
|
<input type="text" id="name" name="name" />
|
|
|
|
</div>
|
|
|
|
<div class="six wide field">
|
2024-01-18 13:20:02 -03:00
|
|
|
<label for="password">Contraseña</label>
|
2023-07-24 20:55:26 -04:00
|
|
|
<input type="password" id="password" name="password" />
|
|
|
|
</div>
|
|
|
|
<button class="ui button" id="enter">Ingresar</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
|
2024-03-13 21:24:52 -03:00
|
|
|
@include('layout.body.scripts.cryptojs')
|
|
|
|
|
2023-07-24 20:55:26 -04:00
|
|
|
@push('page_scripts')
|
|
|
|
<script type="text/javascript">
|
2024-03-13 21:24:52 -03:00
|
|
|
function encryptPassword(password) {
|
|
|
|
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
|
|
|
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
|
|
|
return [passphrase, encrypted.toString()].join('')
|
|
|
|
}
|
2023-07-24 20:55:26 -04:00
|
|
|
function sendLogin(name, password) {
|
2024-03-13 21:24:52 -03:00
|
|
|
const method = 'post'
|
|
|
|
const headers = {
|
|
|
|
Accept: 'json'
|
|
|
|
}
|
|
|
|
const body = new FormData()
|
|
|
|
body.append('name', name)
|
|
|
|
body.append('password', encryptPassword(password))
|
|
|
|
return fetch('{{$urls->base}}/login', {method, headers, body}).then(response => {
|
2023-07-24 20:55:26 -04:00
|
|
|
if (response.ok) {
|
|
|
|
return response.json()
|
|
|
|
}
|
|
|
|
}).then(data => {
|
|
|
|
if (data.login === true) {
|
2023-11-23 00:53:49 -03:00
|
|
|
@if(isset($redirect_uri))
|
2024-03-20 20:55:34 -03:00
|
|
|
window.location = '{{$redirect_uri}}?nocache=' + (new Date()).getTime()
|
2023-11-23 00:53:49 -03:00
|
|
|
@else
|
2024-03-20 20:55:34 -03:00
|
|
|
window.location = '{{$urls->base}}?nocache=' + (new Date()).getTime()
|
2023-11-23 00:53:49 -03:00
|
|
|
@endif
|
2023-07-24 20:55:26 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$(document).ready(() => {
|
|
|
|
$('#login_form').find('input').keypress(event => {
|
|
|
|
if (event.which !== 13) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
$('#enter').click()
|
|
|
|
})
|
|
|
|
$('#enter').click(event => {
|
|
|
|
const form = $('#login_form')
|
|
|
|
const name = form.find('#name').val()
|
|
|
|
const password = form.find('#password').val()
|
|
|
|
sendLogin(name, password)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
@endpush
|