-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgotpassword.html
201 lines (183 loc) · 7.1 KB
/
forgotpassword.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!doctype html>
<html lang="en">
<head>
<title>Discord verification</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-143397381-1"></script>
<script>
function gtag() {
if (!window.dataLayer) {
window.dataLayer = []
}
window.dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'UA-143397381-1')
// magic function that we never call, I assume GA uses this for something?
function getOutboundLink(label) {
gtag('event', 'click', {
'event_category': 'outbound',
'event_label': label,
'transport_type': 'beacon'
})
}
</script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="min/style-min.css" />
<style>
#fouc {
opacity: 1;
-webkit-transition: opacity .33s ease;
transition: opacity .33s ease;
}
.invisible {
opacity: 0!important;
}
</style>
</head>
<body>
<header>
<div class="navbar-fixed">
<nav role="navigation">
<div class="nav-wrapper container">
<a href="index.html" class="brand-logo"><h1>Impact</h1></a>
</div>
</nav>
</div>
</header>
<noscript>
You must have javascript enabled.
</noscript>
<div id="fouc" class="section container invisible">
<form id="get_token" class="row hidden" novalidate>
<p class="input-field col s12">
Enter your email and complete the recaptcha, then we will email you a link so that you can reset your password.
</p>
<div class="input-field col s12">
<input type="email" name="email" id="email" class="validate" required />
<label for="email">Email</label>
</div>
<div class="input-field col s12 g-recaptcha" data-sitekey="6Lf19NcUAAAAADBY-60OxWuSMgr4XMH3aq1BZYRs"></div>
<div class="input-field col s12">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit
</button>
</div>
<p id="get_token_msg" class="col s12 helper-text error"></p>
</form>
<form id="use_token" class="row hidden" novalidate>
<p class="input-field col s12">
Reset your password:
</p>
<div class="input-field col s12 m6">
<input type="password" name="password" id="password" class="validate" autocomplete required pattern="(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{6,}" onchange="form.password2.pattern = RegExp.escape(this.value);" />
<label for="password">Password</label>
<span class="helper-text" data-error="Must be 6 characters or more & include lowercase, uppercase, numeric and symbolic characters"></span>
</div>
<div class="input-field col s12 m6">
<input type="password" name="password2" id="password2" class="validate" autocomplete="off" required pattern="\w" />
<label for="password2">Confirm</label>
<span class="helper-text" data-error="Password does not match"></span>
</div>
<div class="input-field col s12">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit
</button>
</div>
<p id="use_token_msg" class="col s12 input-field helper-text error"></p>
</form>
<p id="success" class="row hidden med_text"></p>
</div>
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js"></script>
<script crossorigin="anonymous" src="https://benjamingr.github.io/RegExp.escape/polyfill.js"></script>
<script type="text/javascript" src="min/modernizr-min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="js/api.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/js/materialize.min.js" async></script>
<script src="https://www.google.com/recaptcha/api.js" async></script>
<script async>
(function (){
function getToken() {
var query = new URLSearchParams(window.location.search)
return query.get("token")
}
function capitalize(text) {
if (typeof text !== "string") return text;
return text.replace(/^[a-z]/, function(letter) {
return letter.toUpperCase();
});
}
$("#get_token").submit(function (event) {
event.preventDefault()
var email = $("#email").val()
var captcha = $("#g-recaptcha-response").val()
// validate
var err = []
if (!email) err.push("Email is required")
if (!captcha) err.push("Recaptcha is required")
$("#get_token_msg").html(err.join("<br>"))
if (err.length > 0) {
return
}
// Send a reset email
api.forgotPassword(email, captcha)
.then(function (result) {
if (result === "success") {
result = "We have emailed you a password reset link"
}
$("#get_token").addClass("hidden")
$("#success")
.removeClass("hidden")
.text(capitalize(result))
})
.catch(function (result) {
$("#get_token_msg").text(capitalize(result))
})
})
$("#use_token").submit(function (event) {
event.preventDefault()
var token = getToken()
var password = $("#password").val()
var password2 = $("#password2").val()
// validate
var err = []
if (!token) err.push("Error: no token provided")
if (!password) err.push("Password is required")
if (password !== password2) err.push("Passwords do not match")
$("#use_token_msg").html(err.join("<br>"))
if (err.length > 0) {
return
}
// Do the meme
api.changePassword(token, password)
.then(function(result) {
if (result === "success") {
result = "Password changed successfully"
}
$("#use_token").addClass("hidden")
$("#success")
.removeClass("hidden")
.text(capitalize(result))
})
.catch(function(result) {
if (result === "invalid reset token") {
$("#use_token_msg").html('Invalid! <a href="forgotpassword.html">Get a new reset link</a>.')
return
}
$("#use_token_msg").text(capitalize(result))
})
})
// show/hide
if (getToken()) {
$("#get_token").addClass("hidden")
$("#use_token").removeClass("hidden")
} else {
$("#get_token").removeClass("hidden")
$("#use_token").addClass("hidden")
}
// Fade in
$("#fouc").removeClass("invisible")
})()
</script>
</body>
</html>