Improve error messages when using oidc with an existing account

If an account was created before locally (by signing up at docspell)
and the same account is later tried to signin via openid, a better
error message is shown in the logs to be able to act on it. The user
won't see any details in the webapp.

Issue: #1827 #1781
This commit is contained in:
eikek
2022-11-04 20:45:30 +01:00
parent dee7534e34
commit 14643ae4d1
2 changed files with 14 additions and 2 deletions

View File

@ -105,6 +105,7 @@ object OpenId {
import dsl._
for {
_ <- logger.debug(s"Setting up external account: ${accountId.asString}")
setup <- backend.signup.setupExternal(ExternalAccount(accountId))
res <- setup match {
case SignupResult.Failure(ex) =>
@ -143,6 +144,7 @@ object OpenId {
import dsl._
for {
_ <- logger.debug(s"Login and verify external account: ${accountId.asString}")
login <- backend.login.loginExternal(config.auth)(accountId)
resp <- login match {
case Login.Result.Ok(session, _) =>
@ -158,7 +160,9 @@ object OpenId {
.map(_.addCookie(CookieData(session).asCookie(baseUrl)))
case failed =>
logger.error(s"External login failed: $failed") *>
logger.error(
s"External login failed: $failed. ${failed.toEither.left.getOrElse("")}"
) *>
SeeOther(location)
}
} yield resp