class Monban::Repository::Auth::Sequel
Public Instance Methods
account_id_by_email(email:)
click to toggle source
# File lib/monban/repository/auth.rb, line 18 def account_id_by_email(email:) db[:account_reset_password_emails] .where(email: email) .select(:account_id) .map{|hash| hash[:account_id] }.first end
account_id_by_login_id(login_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 25 def account_id_by_login_id(login_id:) db[:account_login_ids] .where(login_id: login_id) .select(:account_id) .map{|hash| hash[:account_id] }.first end
account_id_by_public_id(public_id:, now:)
click to toggle source
# File lib/monban/repository/auth.rb, line 10 def account_id_by_public_id(public_id:, now:) db[:account_public_ids] .where(public_id: public_id) .where(::Sequel[:account_public_ids][:expired_at] > now) .select(:account_id) .map{|hash| hash[:account_id] }.first end
authy_id(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 91 def authy_id(account_id:) db[:account_authy_ids] .where(account_id: account_id) .select(:authy_id) .map{|hash| hash[:authy_id]}.first end
delete_reset_password_token(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 114 def delete_reset_password_token(account_id:) db[:account_reset_password_tokens] .where(account_id: account_id) .delete end
insert_public_id(account_id:, public_id:, created_at:, expired_at:)
click to toggle source
# File lib/monban/repository/auth.rb, line 80 def insert_public_id(account_id:, public_id:, created_at:, expired_at:) db[:account_public_ids].insert( account_id: account_id, public_id: public_id, created_at: created_at, expired_at: expired_at, original_created_at: created_at, ) end
insert_reset_password_token(account_id:, reset_token:, created_at:, expired_at:)
click to toggle source
# File lib/monban/repository/auth.rb, line 126 def insert_reset_password_token(account_id:, reset_token:, created_at:, expired_at:) db[:account_reset_password_tokens].insert( account_id: account_id, reset_token: reset_token, created_at: created_at, expired_at: expired_at, ) end
login_id(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 32 def login_id(account_id:) db[:account_login_ids] .where(account_id: account_id) .select(:login_id) .map{|hash| hash[:login_id]}.first end
login_type(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 39 def login_type(account_id:) # all account login with 'authy' in this implement "authy" end
password_hash_match?(account_id:, password_hash:)
click to toggle source
# File lib/monban/repository/auth.rb, line 159 def password_hash_match?(account_id:, password_hash:) not db[:account_password_hashes] .where(account_id: account_id, password_hash: password_hash) .empty? end
password_salt(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 152 def password_salt(account_id:) db[:account_password_hashes] .select(::Sequel.function(:substring, ::Sequel[:password_hash], 1, 30).as(:salt)) .where(account_id: account_id) .map{|hash| hash[:salt]}.first end
preserve_public_id_original_created_at(public_id:, original_created_at:)
click to toggle source
# File lib/monban/repository/auth.rb, line 66 def preserve_public_id_original_created_at(public_id:, original_created_at:) db[:account_public_ids] .where(public_id: public_id) .update( original_created_at: original_created_at, ) end
public_id_exists?(public_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 74 def public_id_exists?(public_id:) not db[:account_public_ids] .where(public_id: public_id) .empty? end
public_id_original_created_at(public_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 59 def public_id_original_created_at(public_id:) db[:account_public_ids] .where(public_id: public_id) .select(:original_created_at) .map{|hash| hash[:original_created_at]}.first end
public_id_renew_enabled?(public_id:, original_created_at:)
click to toggle source
# File lib/monban/repository/auth.rb, line 52 def public_id_renew_enabled?(public_id:, original_created_at:) not db[:account_public_ids] .where(public_id: public_id) .where(::Sequel[:account_public_ids][:original_created_at] > original_created_at) .empty? end
reset_password_token_exists?(reset_token:)
click to toggle source
# File lib/monban/repository/auth.rb, line 120 def reset_password_token_exists?(reset_token:) not db[:account_reset_password_tokens] .where(reset_token: reset_token) .empty? end
roles(account_id:)
click to toggle source
# File lib/monban/repository/auth.rb, line 44 def roles(account_id:) db[:account_roles] .where(account_id: account_id) .select(:role) .map{|r| r[:role]} end
update_authy_id(account_id:, authy_id:, now:)
click to toggle source
# File lib/monban/repository/auth.rb, line 98 def update_authy_id(account_id:, authy_id:, now:) if db[:account_authy_ids].where(account_id: account_id).empty? db[:account_authy_ids].insert( account_id: account_id, authy_id: authy_id, created_at: now, ) else db[:account_authy_ids].where(account_id: account_id).update( authy_id: authy_id, created_at: now, ) end end
update_password_hash(account_id:, password_hash:, now:)
click to toggle source
# File lib/monban/repository/auth.rb, line 165 def update_password_hash(account_id:, password_hash:, now:) if db[:account_password_hashes].where(account_id: account_id).empty? db[:account_password_hashes].insert( account_id: account_id, password_hash: password_hash, created_at: now, updated_at: now, ) else db[:account_password_hashes].where(account_id: account_id).update( password_hash: password_hash, updated_at: now, ) end end
valid_reset_password_token?(account_id:, reset_token:, now:)
click to toggle source
# File lib/monban/repository/auth.rb, line 141 def valid_reset_password_token?(account_id:, reset_token:, now:) not db[:account_reset_password_tokens] .where( account_id: account_id, reset_token: reset_token, ) .where(::Sequel[:account_reset_password_tokens][:expired_at] > now) .empty? end
wipe_old_reset_password_token(now:)
click to toggle source
# File lib/monban/repository/auth.rb, line 135 def wipe_old_reset_password_token(now:) db[:account_reset_password_tokens] .where(::Sequel[:account_reset_password_tokens][:expired_at] <= now) .delete end