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:
Eike Kettner 2021-03-10 22:14:55 +01:00
parent 70b5625c48
commit a4a84abae5
3 changed files with 20 additions and 8 deletions

View File

@ -26,7 +26,7 @@ object Ident {
implicit val identEq: Eq[Ident] = implicit val identEq: Eq[Ident] =
Eq.by(_.id) 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] = def randomUUID[F[_]: Sync]: F[Ident] =
Sync[F].delay(unsafe(UUID.randomUUID.toString)) Sync[F].delay(unsafe(UUID.randomUUID.toString))

View File

@ -1,9 +1,11 @@
module Page.Register.Update exposing (update) module Page.Register.Update exposing (update)
import Api import Api
import Api.Model.BasicResult exposing (BasicResult)
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.Register.Data exposing (..) import Page.Register.Data exposing (..)
import Util.Http
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -106,8 +108,16 @@ update flags msg model =
, cmd , cmd
) )
SubmitResp (Err _) -> SubmitResp (Err err) ->
( model, Cmd.none ) 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 validateForm : Model -> List String

View File

@ -164,12 +164,14 @@ errorToString : Http.Error -> String
errorToString error = errorToString error =
let let
f sc = f sc =
case sc of if sc == 404 then
404 ->
"The requested resource doesn't exist." "The requested resource doesn't exist."
_ -> else if sc >= 400 && sc < 500 then
"There was an invalid response status: " ++ String.fromInt sc "Invalid input when processing the request."
else
"There was an invalid response status: " ++ String.fromInt sc ++ "."
in in
errorToStringStatus error f errorToStringStatus error f