-
-
Save Exact1990/b1299acfd230198d853a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserSignInType | |
| include ApplicationTypeWithoutActiveRecord | |
| attribute :login, String | |
| attribute :password, String | |
| validates :login, :password, presence: true | |
| validate :check_authenticate | |
| def user | |
| User.actual.find_by(login: login) | |
| end | |
| private | |
| def check_authenticate | |
| if login.present? && password.present? | |
| errors.add(:base, :login_or_password_invalid) if !user.try(:authenticate, password) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationTypeWithoutActiveRecord | |
| extend ActiveSupport::Concern | |
| included do | |
| include ActiveModel::Validations | |
| include ActiveModel::Conversion | |
| include ActiveModel::Translation | |
| include Virtus.model | |
| end | |
| def persisted? | |
| false | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment