Skip to content

How to suspend a user from login? #2168

Discussion options

You must be logged in to vote

There is no global toggle for this out of the box.

If you use PocketBase as framework, you can disable the email login for a particular user using the OnRecordBeforeAuthWithPasswordRequest and return an error (or define a global middleware to intercept the /api/collection/users/auth-with-password call).

app.OnRecordBeforeAuthWithPasswordRequest().Add(func(e *core.RecordAuthWithPasswordEvent) error {
	if e.Record != nil && e.Record.Email() == "block@example.com" {
		return apis.NewForbiddenError("You are not allowed to perform this action", nil)
	}

	return nil
})

If you want to disable also the OAuth2 logins for accounts with the specified email, you can make use of the more generic OnRec…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@iamdineshkumar
Comment options

@ganigeorgiev
Comment options

Answer selected by iamdineshkumar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants