Class: Lesli::User::Session

Inherits:
ApplicationLesliRecord show all
Defined in:
app/models/lesli/user/session.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
76
77
78
# File 'app/models/lesli/user/session.rb', line 68

def active?
    if self.deleted_at.present?
        return false
    end

    if self.expiration_at != nil and self.expiration_at < Time.now.utc
        return false
    end

    return true
end

#set_session_tokenObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/lesli/user/session.rb', line 45

def set_session_token

    return if self.session_source == "devise_standard_session"

    return unless self.session_token.blank?

    rebuild_token = true

    while rebuild_token do

        session_token = SecureRandom.alphanumeric(20)

        # assign token to user if token is unique
        unless User::Session.find_by(:session_token => session_token)
            self.session_token = session_token
            self.save!
            rebuild_token = false
        end

    end

end