mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user