mirror of
https://github.com/1f349/tulip.git
synced 2024-11-13 23:31:37 +00:00
Add otp enabled state on the home
This commit is contained in:
parent
68237dfc42
commit
c6ddc7b197
@ -17,7 +17,7 @@
|
||||
<p style="display:none">Raw OTP string: {{.OtpUrl}}</p>
|
||||
<div>
|
||||
<label for="field_code">OTP Code:</label>
|
||||
<input type="text" name="code" id="field_code" required pattern="[0-9]{6,8}" title="6/7/8 digit one time passcode"/>
|
||||
<input type="text" name="code" id="field_code" required autofocus pattern="[0-9]{6,8}" title="6/7/8 digit one time passcode"/>
|
||||
</div>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{.ServiceName}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>{{.ServiceName}}</h1>
|
||||
</header>
|
||||
<main>
|
||||
<form method="POST" action="/edit/password">
|
||||
<div>
|
||||
<label for="field_password">Current Password:</label>
|
||||
<input type="password" name="password" id="field_password" autocomplete="password" autofocus required/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="field_password">New Password:</label>
|
||||
<input type="password" name="password" id="field_password" autocomplete="new_password" required/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="field_password">Retype New Password:</label>
|
||||
<input type="password" name="password" id="field_password" autocomplete="confirm_password" required/>
|
||||
</div>
|
||||
<button type="submit">Change Password</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -14,11 +14,6 @@
|
||||
<button type="submit">Edit Profile</button>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<form method="GET" action="/edit/username">
|
||||
<button type="submit">Change Username</button>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<form method="GET" action="/edit/password">
|
||||
<button type="submit">Change Password</button>
|
||||
@ -34,14 +29,23 @@
|
||||
<button type="submit">Manage Users</button>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<form method="POST" action="/edit/otp">
|
||||
<label><input type="radio" name="digits" value="6"/> 6 digits</label>
|
||||
<label><input type="radio" name="digits" value="7"/> 7 digits</label>
|
||||
<label><input type="radio" name="digits" value="8"/> 8 digits</label>
|
||||
<button type="submit">Change OTP</button>
|
||||
</form>
|
||||
</div>
|
||||
{{if .OtpEnabled}}
|
||||
<div>
|
||||
<form method="POST" action="/edit/otp">
|
||||
<input type="hidden" name="remove" value="1"/>
|
||||
<button type="submit">Remove OTP</button>
|
||||
</form>
|
||||
</div>
|
||||
{{else}}
|
||||
<div>
|
||||
<form method="POST" action="/edit/otp">
|
||||
<label><input type="radio" name="digits" value="6"/> 6 digits</label>
|
||||
<label><input type="radio" name="digits" value="7"/> 7 digits</label>
|
||||
<label><input type="radio" name="digits" value="8"/> 8 digits</label>
|
||||
<button type="submit">Change OTP</button>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
<div>
|
||||
<form method="POST" action="/logout">
|
||||
<input type="hidden" name="nonce" value="{{.Nonce}}">
|
||||
|
@ -12,7 +12,7 @@
|
||||
<input type="hidden" name="redirect" value="{{.Redirect}}"/>
|
||||
<div>
|
||||
<label for="field_code">OTP Code:</label>
|
||||
<input type="text" name="code" id="field_code" required pattern="[0-9]{6,8}" title="6/7/8 digit one time passcode" autocomplete="off" aria-autocomplete="none" role="presentation"/>
|
||||
<input type="text" name="code" id="field_code" required pattern="[0-9]{6,8}" title="6/7/8 digit one time passcode" autocomplete="off" autofocus aria-autocomplete="none" role="presentation"/>
|
||||
</div>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
@ -1,26 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{.Title}}</title>
|
||||
<style>
|
||||
#app > h1 {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media screen and (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
color: #d2d2d2;
|
||||
background-color: #1c1b22;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<h1>{{.Title}}</h1>
|
||||
<p>Hi {{.Name}},</p>
|
||||
<p>Here is your email verification code: <span>{{.Code}}</span></p>
|
||||
<p>{{.ServiceName}}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -27,11 +27,16 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute
|
||||
}
|
||||
|
||||
var userWithName *database.User
|
||||
var hasTwoFactor bool
|
||||
if h.DbTx(rw, func(tx *database.Tx) (err error) {
|
||||
userWithName, err = tx.GetUserDisplayName(auth.Data.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user display name: %w", err)
|
||||
}
|
||||
hasTwoFactor, err = tx.HasTwoFactor(auth.Data.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user two factor state: %w", err)
|
||||
}
|
||||
return
|
||||
}) {
|
||||
return
|
||||
@ -41,5 +46,6 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute
|
||||
"Auth": auth,
|
||||
"User": userWithName,
|
||||
"Nonce": lNonce,
|
||||
"OtpEnabled": hasTwoFactor,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user