Sha256: 2d671ce1f2e323119f7fdda1eaf0fce4949a972d323960ae145f25aa1751fc2d
Contents?: true
Size: 810 Bytes
Versions: 56
Compression:
Stored size: 810 Bytes
Contents
require 'active_model' module EtFakeCcd module Command class LoginUserCommand include ActiveModel::Model include ActiveModel::Attributes def initialize(config: ::EtFakeCcd::Config.instance, **args) self.config = config super(**args) end attribute :username attribute :password def self.from_json(json) new username: json['username'], password: json['password'] end validate :validate_username_and_password private attr_accessor :config def validate_username_and_password return if config.valid_credentials.any? do |cred| username == cred[:username] && password == cred[:password] end errors.add(:username, "Invalid username or password") end end end end
Version data entries
56 entries across 56 versions & 1 rubygems