mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-14 21:59:05 +02:00
feat: add ability to force email verification (#1837)
This commit is contained in:
@@ -85,6 +85,11 @@ func (m *Middleware) require(scope Scope, optional bool) gin.HandlerFunc {
|
||||
// A valid credential without the scope is forbidden even on optional routes, so a caller is never silently downgraded to anonymous
|
||||
if !principal.Scopes.Has(scope) {
|
||||
c.Abort()
|
||||
// A scope that is only withheld until the email is verified tells the user how to regain it
|
||||
if principal.WithheldUntilVerified.Has(scope) {
|
||||
_ = c.Error(apperror.EmailVerificationRequired())
|
||||
return
|
||||
}
|
||||
_ = c.Error(apperror.MissingScope(string(scope)))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user