class Opium::User
Public Class Methods
authenticate( username, password )
click to toggle source
Note that this will eat any ParseErrors which get raised, and not perform any logging.
# File lib/opium/user.rb, line 17 def authenticate( username, password ) authenticate!( username, password ) rescue Opium::Model::Connectable::ParseError => e nil end
authenticate!( username, password )
click to toggle source
# File lib/opium/user.rb, line 23 def authenticate!( username, password ) new( as_resource('login') { http_get query: { username: username, password: password } } ) end
find_by_session_token( token )
click to toggle source
# File lib/opium/user.rb, line 27 def find_by_session_token( token ) data = http_get id: 'me', headers: { x_parse_session_token: token } new( data.except( '__type', 'className' ) ) end
Public Instance Methods
reset_password()
click to toggle source
# File lib/opium/user.rb, line 33 def reset_password reset_password! rescue => e self.errors.add( :email, e.to_s ) false end
reset_password!()
click to toggle source
# File lib/opium/user.rb, line 40 def reset_password! fail KeyError, 'an email address is required to reset password' unless email self.class.as_resource('requestPasswordReset') { self.class.http_post data: email }.empty? end