Skip to content

form_user is invalid and is not listed in SwitchUser#available_users #81

@chrisyeung1121

Description

@chrisyeung1121

I have FormUser Model which belongs to User model, and in my FormUser model is to tak care of omniauth schemes login with email password logins. When I try to use the switch back feature, the following error apepars.

SwitchUser::InvalidScope in SwitchUserController#remember_user
form_user is invalid and is not listed in SwitchUser#available_users

My form user model is as below.

class FormUser < User
    attr_accessor :current_password

    validates_presence_of :email, if: :email_required?
    validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
    validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed?

    validates_presence_of :password, if: :password_required?
    validates_confirmation_of :password, if: :password_required?
    validates_length_of :password, within: Devise.password_length, allow_blank: true

    def password_required?
        return false if email.blank?
        !persisted? || !password.nil? || !password_confirmation.nil?
    end

    def email_required?
        true
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions