forked from stadust/pointercrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogin.rs
More file actions
83 lines (73 loc) · 3.32 KB
/
login.rs
File metadata and controls
83 lines (73 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use maud::{html, Markup};
use pointercrate_core::localization::{task_lang, tr};
use pointercrate_core_pages::{head::HeadLike, trp_html, PageFragment};
use pointercrate_user::config;
pub fn login_page() -> PageFragment {
let mut frag = PageFragment::new(
"Pointercrate - Login",
"Log in to an existing pointercrate account or register for a new one!",
)
.module("/static/user/js/login.js")
.module("/static/core/js/modules/form.js")
.module("/static/core/js/modules/tab.js")
.stylesheet("/static/user/css/login.css")
.body(login_page_body());
if cfg!(feature = "oauth2") {
frag = frag.async_script("https://accounts.google.com/gsi/client");
}
frag
}
fn login_page_body() -> Markup {
let lang = task_lang();
html! {
div.center #login style="display: flex; align-items: center; justify-content: center; height: calc(100% - 70px)" { // 70px = height of nav bar
div.flex.col style="align-items: center" {
div.panel.fade {
h1.underlined.pad {
(tr("login"))
}
@if cfg!(feature = "oauth2") {
p {
(tr("login.oauth-info"))
}
div #g_id_onload
data-ux_mode="popup"
data-auto_select="true"
data-itp_support="true"
data-client_id=(config::google_client_id())
data-callback="googleOauthCallback" {}
script src=(format!("https://accounts.google.com/gsi/client?hl={}", &lang)) async {}
div .g_id_signin data-text="continue_with" style="margin: 10px 0px" data-locale=(lang) {}
p.error #g-signin-error style="text-align: left" {}
p.or style="text-size: small; margin: 0px" { (tr("login.methods-separator")) }
}
p {
(tr("login.info"))
}
form.flex.col #login-form novalidate = "" {
p.info-red.output {}
span.form-input #login-username {
label for = "username" {(tr("auth-username")) }
input required = "" type = "text" name = "username" minlength = "3";
p.error {}
}
span.form-input #login-password {
label for = "password" {(tr("auth-password")) }
input required = "" type = "password" name = "password" minlength = "10";
p.error {}
}
input.button.blue.hover type = "submit" style = "margin: 15px auto 0px;" value = (tr("login.submit"));
}
}
p style = "text-align: center; padding: 0px 10px" {
(trp_html!(
"register.redirect",
"redirect-link" = html! {
a.link href="/register/" { (tr("register.redirect-link")) }
}
))
}
}
}
}
}