mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Show errors from failed register request
Also include a `@` in the valid chars for "idents". This allows to use an e-mail address as username.
This commit is contained in:
parent
70b5625c48
commit
a4a84abae5
@ -26,7 +26,7 @@ object Ident {
|
||||
implicit val identEq: Eq[Ident] =
|
||||
Eq.by(_.id)
|
||||
|
||||
val chars: Set[Char] = (('A' to 'Z') ++ ('a' to 'z') ++ ('0' to '9') ++ "-_.").toSet
|
||||
val chars: Set[Char] = (('A' to 'Z') ++ ('a' to 'z') ++ ('0' to '9') ++ "-_.@").toSet
|
||||
|
||||
def randomUUID[F[_]: Sync]: F[Ident] =
|
||||
Sync[F].delay(unsafe(UUID.randomUUID.toString))
|
||||
|
@ -1,9 +1,11 @@
|
||||
module Page.Register.Update exposing (update)
|
||||
|
||||
import Api
|
||||
import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Register.Data exposing (..)
|
||||
import Util.Http
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
@ -106,8 +108,16 @@ update flags msg model =
|
||||
, cmd
|
||||
)
|
||||
|
||||
SubmitResp (Err _) ->
|
||||
( model, Cmd.none )
|
||||
SubmitResp (Err err) ->
|
||||
let
|
||||
errMsg =
|
||||
Util.Http.errorToString err
|
||||
|
||||
res =
|
||||
BasicResult False
|
||||
(errMsg ++ " Please check the form and try again.")
|
||||
in
|
||||
( { model | result = Just res }, Cmd.none )
|
||||
|
||||
|
||||
validateForm : Model -> List String
|
||||
|
@ -164,12 +164,14 @@ errorToString : Http.Error -> String
|
||||
errorToString error =
|
||||
let
|
||||
f sc =
|
||||
case sc of
|
||||
404 ->
|
||||
"The requested resource doesn't exist."
|
||||
if sc == 404 then
|
||||
"The requested resource doesn't exist."
|
||||
|
||||
_ ->
|
||||
"There was an invalid response status: " ++ String.fromInt sc
|
||||
else if sc >= 400 && sc < 500 then
|
||||
"Invalid input when processing the request."
|
||||
|
||||
else
|
||||
"There was an invalid response status: " ++ String.fromInt sc ++ "."
|
||||
in
|
||||
errorToStringStatus error f
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user