Skip to content

[Feature] Disable user login #3565

Closed
Closed
@Mardaneus86

Description

@Mardaneus86

Introduction

Being able to disable a user so he can no longer use the login function without removing the user object.

Motivation

Disabling a user allows you to temporarily remove access to his account without removing all links or ACL's on existing objects. This way the user could be re-enabled in the future and still have access to his old objects.

Proposed solution

  1. Add a flag to the User class that says if the user is disabled or not. The UsersRouter could be enhanced to take this flag into account.

  2. Another, more flexible, option would be to allow an override for the UsersController and inject that into the UsersRouter handleLogin flow. This way the developer can come up with custom flags to prevent a user from logging in, but this may be overkill.

Detailed design

  1. Expand the User schema with a enabled or disabled flag in the SchemaController. Check for this flag in the handleLogin method of the UsersRouter.

  2. Inject a allowLogin hook from the UsersController into the handleLogin method of the UsersRouter that returns a boolean. A developer would implement his own version of the UsersController and override this allowLogin method.

Alternatives considered

  • Using a Cloud Code function to handle the login and return a session token. You could use the become method on the client to login. However this prevents developers from using the normal login methods, and doesn't prevent a malicious user to still use the regular login method that doesn't take the extra check into account.

  • Account lockout: this is only a temporary measure where the account is disabled for a fixed amount of time and also serves another purpose than what is wanted here.

I tested a basic implementation of this proposal on my own fork. However it's still missing unit tests, and I don't know if this is functionality that could be used broadly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions