generated from mirzaev/pot
большая разработка аутентификации
This commit is contained in:
@@ -1,26 +1,17 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
class account {
|
||||
static async initialization() {
|
||||
// Запрос
|
||||
return fetch('https://auth.mirzaev.sexy/account/initialization', {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
static async initialization() {
|
||||
// Запрос
|
||||
return await fetch('https://account.mirzaev.sexy/account/initialization', {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
static authentication() {
|
||||
// Инициализация аккаунта
|
||||
alert(1);
|
||||
this.initialization()
|
||||
.then(
|
||||
(response) => {
|
||||
alert(2);
|
||||
}
|
||||
);
|
||||
static deauthentication() {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static deauthentication() {
|
||||
}
|
||||
static registration() {
|
||||
alert(228);
|
||||
}
|
||||
}
|
||||
|
@@ -1,2 +1 @@
|
||||
/*! js-cookie v3.0.1 | MIT */
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}));
|
31
mirzaev/site/account/system/public/js/damper.js
Normal file
31
mirzaev/site/account/system/public/js/damper.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Демпфер
|
||||
*
|
||||
* @param {function} func Функция
|
||||
* @param {number} timeout Таймер (ms)
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function damper(func, timeout = 300) {
|
||||
// Инициализация таймера
|
||||
let timer;
|
||||
|
||||
return (...args) => {
|
||||
// Деинициализация таймера
|
||||
clearTimeout(timer);
|
||||
|
||||
// Вызов функции (вход в рекурсию)
|
||||
timer = setTimeout(() => {
|
||||
func.apply(this, args);
|
||||
}, timeout);
|
||||
};
|
||||
}
|
||||
|
||||
// Вызов события "Инициализирован демпфер"
|
||||
document.dispatchEvent(
|
||||
new CustomEvent("damper.initialized", {
|
||||
detail: { damper }
|
||||
})
|
||||
);
|
24
mirzaev/site/account/system/public/js/password.js
Normal file
24
mirzaev/site/account/system/public/js/password.js
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
class password {
|
||||
/**
|
||||
* Сгенерировать
|
||||
*
|
||||
* @param {number} length Длина (количество слов в мнемоническом, либо символов в классическом)
|
||||
*
|
||||
* @return {object} {(string) password, (array) errors}
|
||||
*/
|
||||
static async generate(length = 12, type = "classic") {
|
||||
return await fetch("https://account.mirzaev.sexy/api/generate/password", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: `length=${length}&type=${type}&return=password,errors`,
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
}
|
75
mirzaev/site/account/system/public/js/session.js
Normal file
75
mirzaev/site/account/system/public/js/session.js
Normal file
@@ -0,0 +1,75 @@
|
||||
'use strict';
|
||||
|
||||
class session {
|
||||
/**
|
||||
* Отправить входной псевдоним на сервер
|
||||
*
|
||||
* Записывает входной псевдоним в сессию, а так же проверяет существование аккаунта с ним
|
||||
*
|
||||
* @param {string} login Входной
|
||||
*
|
||||
* @return {object} {(bool) exist, (array) errors}
|
||||
*/
|
||||
static async login(login) {
|
||||
// Запрос
|
||||
return await fetch('https://account.mirzaev.sexy/session/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `login=${login}&remember=1&return=exist,errors`
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправить пароль на сервер
|
||||
*
|
||||
* Записывает пароль в сессию, а так же проверяет его на соответствование требованиям
|
||||
*
|
||||
* @param {string} password Пароль
|
||||
*
|
||||
* @return {object} {(bool) verify, (array) errors}
|
||||
*/
|
||||
static async password(password) {
|
||||
// Запрос
|
||||
return await fetch('https://account.mirzaev.sexy/session/password', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `password=${password}&return=verify,errors`
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправить ключ приглашения на сервер
|
||||
*
|
||||
* Записывает ключ приглашения в сессию, а так же проверяет существование приглашения
|
||||
*
|
||||
* @param {string} invite Ключ приглашения
|
||||
*
|
||||
* @return {object} {(bool) exist, (array) from, (array) errors}
|
||||
*/
|
||||
static async invite(invite) {
|
||||
// Запрос
|
||||
return await fetch("https://account.mirzaev.sexy/session/invite", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: `invite=${invite}&remember=1&return=exist,from,errors`,
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user