summaryrefslogtreecommitdiff
path: root/view/login.templ
blob: 56e003c3a46757135167a1b9638cc78517356f8c (plain)
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
package view

import (
    "stevenlr.com/locker/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 class="error">{ 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, "")
}