mirror of
https://github.com/1f349/tulip.git
synced 2024-12-22 16:24:10 +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>
|
<p style="display:none">Raw OTP string: {{.OtpUrl}}</p>
|
||||||
<div>
|
<div>
|
||||||
<label for="field_code">OTP Code:</label>
|
<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>
|
</div>
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</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>
|
<button type="submit">Edit Profile</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<form method="GET" action="/edit/username">
|
|
||||||
<button type="submit">Change Username</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<form method="GET" action="/edit/password">
|
<form method="GET" action="/edit/password">
|
||||||
<button type="submit">Change Password</button>
|
<button type="submit">Change Password</button>
|
||||||
@ -34,14 +29,23 @@
|
|||||||
<button type="submit">Manage Users</button>
|
<button type="submit">Manage Users</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{{if .OtpEnabled}}
|
||||||
<form method="POST" action="/edit/otp">
|
<div>
|
||||||
<label><input type="radio" name="digits" value="6"/> 6 digits</label>
|
<form method="POST" action="/edit/otp">
|
||||||
<label><input type="radio" name="digits" value="7"/> 7 digits</label>
|
<input type="hidden" name="remove" value="1"/>
|
||||||
<label><input type="radio" name="digits" value="8"/> 8 digits</label>
|
<button type="submit">Remove OTP</button>
|
||||||
<button type="submit">Change OTP</button>
|
</form>
|
||||||
</form>
|
</div>
|
||||||
</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>
|
<div>
|
||||||
<form method="POST" action="/logout">
|
<form method="POST" action="/logout">
|
||||||
<input type="hidden" name="nonce" value="{{.Nonce}}">
|
<input type="hidden" name="nonce" value="{{.Nonce}}">
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<input type="hidden" name="redirect" value="{{.Redirect}}"/>
|
<input type="hidden" name="redirect" value="{{.Redirect}}"/>
|
||||||
<div>
|
<div>
|
||||||
<label for="field_code">OTP Code:</label>
|
<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>
|
</div>
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</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 userWithName *database.User
|
||||||
|
var hasTwoFactor bool
|
||||||
if h.DbTx(rw, func(tx *database.Tx) (err error) {
|
if h.DbTx(rw, func(tx *database.Tx) (err error) {
|
||||||
userWithName, err = tx.GetUserDisplayName(auth.Data.ID)
|
userWithName, err = tx.GetUserDisplayName(auth.Data.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get user display name: %w", err)
|
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
|
||||||
}) {
|
}) {
|
||||||
return
|
return
|
||||||
@ -41,5 +46,6 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute
|
|||||||
"Auth": auth,
|
"Auth": auth,
|
||||||
"User": userWithName,
|
"User": userWithName,
|
||||||
"Nonce": lNonce,
|
"Nonce": lNonce,
|
||||||
|
"OtpEnabled": hasTwoFactor,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user