Class: ModSpox::Models::Auth

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/mod_spox/models/Auth.rb

Overview

Attributes provided by model:

password

Password to autenticate against

services

Authentication by nickserv

mask

Mask to authenticate source against

authed

Nick has authenticated

Instance Method Summary collapse

Instance Method Details

#before_destroyObject

Clear relations before destroying



17
18
19
# File 'lib/mod_spox/models/Auth.rb', line 17

def before_destroy
    remove_all_groups
end

#check_mask(source) ⇒ Object

source

source to apply mask to

Check and authenticate by mask against source



58
59
60
# File 'lib/mod_spox/models/Auth.rb', line 58

def check_mask(source)
    authed = true if source =~ /^#{mask}$/
end

#check_password(pass) ⇒ Object

pass

password to compare

Check and authenticate against password



42
43
44
45
46
47
48
49
# File 'lib/mod_spox/models/Auth.rb', line 42

def check_password(pass)
    if(Digest::SHA1.hexdigest(pass) == password)
        update(:authed => true)
        return true
    else
        return false
    end
end

#password=(pass) ⇒ Object



51
52
53
54
# File 'lib/mod_spox/models/Auth.rb', line 51

def password=(pass)
    pass = pass.nil? ? nil : Digest::SHA1.hexdigest(pass)
    super(pass)
end

#servicesObject

Is nick identified with services



22
23
24
25
26
27
28
29
# File 'lib/mod_spox/models/Auth.rb', line 22

def services
    s = values[:services]
    if(s == 0 || s == '0' || !s)
        return false
    else
        return true
    end
end

#services_identified=(val) ⇒ Object

Set services (nickserv) identification



32
33
34
35
36
37
38
# File 'lib/mod_spox/models/Auth.rb', line 32

def services_identified=(val)
    if(val && services)
        update(:authed => true)
    else
        update(:authed => false)
    end
end