mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-29 00:44:52 +09:00
New sharer ident checked for CI-uniqueness
This commit is contained in:
parent
1a3f976a81
commit
a0d42f9159
1 changed files with 10 additions and 9 deletions
|
@ -19,9 +19,11 @@ module Vervis.Field.Person
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Vervis.Import
|
import Vervis.Import hiding ((==.))
|
||||||
|
|
||||||
import Data.Char (isDigit)
|
import Data.Char (isDigit)
|
||||||
|
import Database.Esqueleto
|
||||||
|
|
||||||
import Data.Char.Local (isAsciiLetter)
|
import Data.Char.Local (isAsciiLetter)
|
||||||
|
|
||||||
checkLoginTemplate :: Field Handler Text -> Field Handler Text
|
checkLoginTemplate :: Field Handler Text -> Field Handler Text
|
||||||
|
@ -40,13 +42,12 @@ checkLoginTemplate =
|
||||||
in checkBool ok msg
|
in checkBool ok msg
|
||||||
|
|
||||||
checkLoginUnique :: Field Handler Text -> Field Handler Text
|
checkLoginUnique :: Field Handler Text -> Field Handler Text
|
||||||
checkLoginUnique = checkM $ \ login -> runDB $ do
|
checkLoginUnique = checkM $ \ login -> do
|
||||||
let sharer = Sharer
|
sames <- runDB $ select $ from $ \ sharer -> do
|
||||||
{ sharerIdent = login
|
where_ $ lower_ (sharer ^. SharerIdent) ==. lower_ (val login)
|
||||||
, sharerName = Nothing
|
limit 1
|
||||||
}
|
return ()
|
||||||
mus <- checkUnique sharer
|
return $ if null sames
|
||||||
return $ if isNothing mus
|
|
||||||
then Right login
|
then Right login
|
||||||
else Left ("This username is already in use" :: Text)
|
else Left ("This username is already in use" :: Text)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue