v1.0.0
This commit is contained in:
17
web/lib/pages/auth/index.html
Normal file
17
web/lib/pages/auth/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<div id="page-auth">
|
||||
<form id="page-auth-form">
|
||||
<div>
|
||||
<input
|
||||
type="text"
|
||||
name="uuid"
|
||||
id="auth-forms-uuid"
|
||||
placeholder="UUID"
|
||||
required=""
|
||||
/>
|
||||
|
||||
<button type="submit">
|
||||
<span>Авторизуватися</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
47
web/lib/pages/auth/script.js
Normal file
47
web/lib/pages/auth/script.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const Auth = {
|
||||
init: async () => {
|
||||
let html = await fetch('/lib/pages/auth/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
|
||||
document.getElementById("page-auth-form").addEventListener("submit", async function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let uuid = document.getElementById("auth-forms-uuid").value;
|
||||
|
||||
uuid = uuid.replace("https://sheep-service.com/?uuid=", "");
|
||||
uuid = uuid.replace("https://sheep-service.com?uuid=", "");
|
||||
uuid = uuid.replace("https://sheep-service.com?/hash=", "");
|
||||
uuid = uuid.replace("https://sheep-service.com?hash=", "");
|
||||
|
||||
console.log(uuid);
|
||||
|
||||
const URL = `${CONFIG.api}auth`;
|
||||
USER = await fetch(URL, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json, text/plain, */*",
|
||||
"Authorization": uuid
|
||||
}
|
||||
}).then(response => {
|
||||
if (response.status === 401) {
|
||||
localStorage.removeItem("uuid");
|
||||
Router.navigate(`/auth`);
|
||||
} else {
|
||||
localStorage.setItem("uuid", uuid);
|
||||
Router.navigate(`/`, false);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
});
|
||||
|
||||
console.log("USER Info: ", USER);
|
||||
|
||||
|
||||
if (USER.possibilities.can_view_sheeps) document.getElementById("li-sheeps").style.display = "";
|
||||
if (USER.possibilities.can_add_schedule) document.getElementById("li-schedule").style.display = "";
|
||||
if (USER.possibilities.can_manager_territory) document.getElementById("li-territory").style.display = "";
|
||||
if (USER.possibilities.can_view_stand) document.getElementById("li-stand").style.display = "";
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
58
web/lib/pages/auth/style.css
Normal file
58
web/lib/pages/auth/style.css
Normal file
@@ -0,0 +1,58 @@
|
||||
#page-auth {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-height: calc(100% + 70px);
|
||||
margin: 5px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#page-auth-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow-y: auto;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
#page-auth-form>div {
|
||||
border-radius: var(--border-radius);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 160px;
|
||||
justify-content: center;
|
||||
width: 250px;
|
||||
padding: 10px 20px;
|
||||
background: var(--ColorThemes1);
|
||||
color: var(--ColorThemes3);
|
||||
border: 1px solid var(--ColorThemes2);
|
||||
box-shadow: var(--shadow-l1);
|
||||
transition: all .2s ease 0s;
|
||||
}
|
||||
|
||||
#page-auth-form>div>input {
|
||||
background: var(--ColorThemes0);
|
||||
font-size: var(--FontSize2);
|
||||
width: calc(100% - 10px);
|
||||
padding: 0 5px;
|
||||
border-radius: 6px;
|
||||
height: 30px;
|
||||
background-color: var(--ColorThemes0);
|
||||
color: var(--ColorThemes3);
|
||||
}
|
||||
|
||||
#page-auth-form>div>button {
|
||||
border-radius: 6px;
|
||||
background: var(--PrimaryColor);
|
||||
color: var(--PrimaryColorText);
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin: 20px 0 0 0;
|
||||
}
|
||||
#page-auth-form>div>button>span {
|
||||
font-size: var(--FontSize2);
|
||||
font-weight: 400;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
Reference in New Issue
Block a user