30 lines
870 B
Plaintext
30 lines
870 B
Plaintext
package view
|
|
|
|
import (
|
|
"stevenlr.com/timer/model"
|
|
)
|
|
|
|
templ LoginFormError(currentUser *model.User, err string) {
|
|
<div class="login-form">
|
|
if currentUser == nil {
|
|
<form hx-post="/login" hx-target-error="closest .login-form">
|
|
<p>
|
|
<input type="text" name="user" placeholder="User" />
|
|
<input type="password" name="password" placeholder="Password" />
|
|
<button type="submit">Sign in</button>
|
|
if err != "" {
|
|
<span style="color:red;">{ err }</span>
|
|
}
|
|
</p>
|
|
</form>
|
|
} else {
|
|
<p>Signed in as { currentUser.Name } <button type="button" hx-post="/logout" hx-refresh>Sign out</button></p>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
templ LoginForm(currentUser *model.User) {
|
|
@LoginFormError(currentUser, "")
|
|
}
|
|
|