UserServices.js
Home
/
FileServer /
Web /
Scripts /
Services /
UserServices.js
class UserServices {
constructor() {
this.URL_Auth = "/User/Auth?";
}
Auth(login, password) {
let url = this.URL_Auth + "Login=" + login + "&Password=" + password;
return fetch(
url,
{
//Login: login,
//Password: password
});
}
//Возвращает true если пользователь авторизован
IsAuth() {
let token = this.GetTocken();
return token != "";
}
_getCookie(name) {
let matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : "";
}
//Токен авторизации
GetTocken() {
return this._getCookie("AuthToken");
}
//задать токен
SetTocken(val) {
document.cookie = "AuthToken=" + val;
}
//Возвращает true если пользователь авторизован
IsAuth() {
let token = this.GetTocken();
return token != "";
}
}