A calendar management project, for events and activities related to communities fighting for freedoms.
This can be related to software, art, data, hardware, content, commons, internet.
https://www.agendadulibre.org
This can be related to software, art, data, hardware, content, commons, internet.
https://www.agendadulibre.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1009 B
44 lines
1009 B
require 'digest/md5' |
|
|
|
# Moderators, but using a failed pwd mechanism |
|
# TODO, migrate to full active_admin |
|
class User < ActiveRecord::Base |
|
# Include default devise modules. Others available are: |
|
# :confirmable, :lockable, :timeoutable and :omniauthable |
|
devise :database_authenticatable, authentication_keys: [:login] |
|
# :registerable, :validatable |
|
|
|
has_many :notes |
|
|
|
def encrypted_password=(pass) |
|
self[:password] = pass |
|
end |
|
|
|
def encrypted_password |
|
self[:password] |
|
end |
|
|
|
def self.find_first_by_auth_conditions(warden_conditions) |
|
conditions = warden_conditions.dup |
|
login = conditions.delete(:login) |
|
if login.present? |
|
where(conditions).where(['login = :value', { value: login }]).first |
|
else |
|
where(conditions).first |
|
end |
|
end |
|
|
|
def valid_password?(password) |
|
encrypted_password == password_digest(password) |
|
end |
|
|
|
def to_s |
|
"#{firstname} #{lastname}" |
|
end |
|
|
|
protected |
|
|
|
def password_digest(password) |
|
Digest::MD5.hexdigest password |
|
end |
|
end
|
|
|