Encriptar clave
This commit is contained in:
@ -16,19 +16,24 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.cryptojs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function encryptPassword(password) {
|
||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
||||
return [passphrase, encrypted.toString()].join('')
|
||||
}
|
||||
function sendLogin(name, password) {
|
||||
const data = new FormData()
|
||||
data.append('name', name)
|
||||
data.append('password', password)
|
||||
return fetch('{{$urls->base}}/login', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
Accept: 'json'
|
||||
},
|
||||
body: data
|
||||
}).then(response => {
|
||||
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 => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
|
Reference in New Issue
Block a user