mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Prepare remember-me authentication variant
This commit is contained in:
@ -12,6 +12,7 @@ import Page exposing (Page(..))
|
||||
type alias Model =
|
||||
{ username : String
|
||||
, password : String
|
||||
, rememberMe : Bool
|
||||
, result : Maybe AuthResult
|
||||
}
|
||||
|
||||
@ -20,6 +21,7 @@ emptyModel : Model
|
||||
emptyModel =
|
||||
{ username = ""
|
||||
, password = ""
|
||||
, rememberMe = False
|
||||
, result = Nothing
|
||||
}
|
||||
|
||||
@ -27,5 +29,6 @@ emptyModel =
|
||||
type Msg
|
||||
= SetUsername String
|
||||
| SetPassword String
|
||||
| ToggleRememberMe
|
||||
| Authenticate
|
||||
| AuthResp (Result Http.Error AuthResult)
|
||||
|
@ -19,8 +19,18 @@ update referrer flags msg model =
|
||||
SetPassword str ->
|
||||
( { model | password = str }, Cmd.none, Nothing )
|
||||
|
||||
ToggleRememberMe ->
|
||||
( { model | rememberMe = not model.rememberMe }, Cmd.none, Nothing )
|
||||
|
||||
Authenticate ->
|
||||
( model, Api.login flags (UserPass model.username model.password) AuthResp, Nothing )
|
||||
let
|
||||
userPass =
|
||||
{ account = model.username
|
||||
, password = model.password
|
||||
, rememberMe = Just model.rememberMe
|
||||
}
|
||||
in
|
||||
( model, Api.login flags userPass AuthResp, Nothing )
|
||||
|
||||
AuthResp (Ok lr) ->
|
||||
let
|
||||
|
@ -3,7 +3,7 @@ module Page.Login.View exposing (view)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput, onSubmit)
|
||||
import Html.Events exposing (onCheck, onInput, onSubmit)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Login.Data exposing (..)
|
||||
|
||||
@ -59,6 +59,19 @@ view flags model =
|
||||
, i [ class "lock icon" ] []
|
||||
]
|
||||
]
|
||||
, div [ class "field" ]
|
||||
[ div [ class "ui checkbox" ]
|
||||
[ input
|
||||
[ type_ "checkbox"
|
||||
, onCheck (\_ -> ToggleRememberMe)
|
||||
, checked model.rememberMe
|
||||
]
|
||||
[]
|
||||
, label []
|
||||
[ text "Remember Me"
|
||||
]
|
||||
]
|
||||
]
|
||||
, button
|
||||
[ class "ui primary fluid button"
|
||||
, type_ "submit"
|
||||
|
Reference in New Issue
Block a user