Fix adding a new user and don't allow to add non-local users

The user structure must provide the correct account source now.
This commit is contained in:
eikek
2021-09-07 21:59:38 +02:00
parent 8df235e9db
commit 736968b049
3 changed files with 10 additions and 4 deletions

View File

@ -214,10 +214,13 @@ object OCollective {
store.transact(RUser.findAll(collective, _.login))
def add(s: RUser): F[AddResult] =
store.add(
RUser.insert(s.copy(password = PasswordCrypt.crypt(s.password))),
RUser.exists(s.login)
)
if (s.source != AccountSource.Local)
AddResult.failure(new Exception("Only local accounts can be created!")).pure[F]
else
store.add(
RUser.insert(s.copy(password = PasswordCrypt.crypt(s.password))),
RUser.exists(s.login)
)
def update(s: RUser): F[AddResult] =
store.add(RUser.update(s), RUser.exists(s.login))