Class: GAE::User

Inherits:
Object
  • Object
show all
Defined in:
lib/rb-gae-support/user_service.rb

Overview

This class represents the User service. It can be used to detemine if a user is logged in, if they are an admin, and retrieve their email, nickname and auth domain. It also provides the login and logout URLs.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#auth_domainObject (readonly)

Returns the value of attribute auth_domain.



8
9
10
# File 'lib/rb-gae-support/user_service.rb', line 8

def auth_domain
  @auth_domain
end

#emailObject (readonly)

Returns the value of attribute email.



8
9
10
# File 'lib/rb-gae-support/user_service.rb', line 8

def email
  @email
end

#nicknameObject (readonly)

Returns the value of attribute nickname.



8
9
10
# File 'lib/rb-gae-support/user_service.rb', line 8

def nickname
  @nickname
end

Class Method Details

.admin?Boolean

Returns true if the user is marked as an admin, false if not.

Returns:

  • (Boolean)


39
40
41
# File 'lib/rb-gae-support/user_service.rb', line 39

def self.admin?
  UserServiceFactory.user_service.user_logged_in? && UserServiceFactory.user_service.user_admin?
end

.currentObject

Returns the current logged in user object, or false if not logged in



11
12
13
14
15
16
17
18
19
# File 'lib/rb-gae-support/user_service.rb', line 11

def self.current
  # load from GAE and return, set vars
  if UserServiceFactory.user_service.user_logged_in?
    gu = UserServiceFactory.user_service.get_current_user
    return User.new(gu.getEmail, gu.getNickname, gu.getAuthDomain)
  else
    return false
  end
end

.logged_in?Boolean

Returns true if the user is logged in, false if not

Returns:

  • (Boolean)


34
35
36
# File 'lib/rb-gae-support/user_service.rb', line 34

def self.logged_in?
  UserServiceFactory.user_service.user_logged_in?
end

.login_url(return_to) ⇒ Object

Returns the URL for the login form. Pass in the relative URL you wish to return to when the login is complete



23
24
25
# File 'lib/rb-gae-support/user_service.rb', line 23

def self.(return_to)
  UserServiceFactory.user_service.(return_to)
end

.logout_url(return_to) ⇒ Object

Returns the URL to log out the user. Pass in the relative URL you wish to return to when the logout is complete



29
30
31
# File 'lib/rb-gae-support/user_service.rb', line 29

def self.logout_url(return_to)
  UserServiceFactory.user_service.create_logout_url(return_to)
end