Class: Ucenter::Interface::User

Inherits:
Base
  • Object
show all
Defined in:
lib/ucenter/interface/user.rb

Instance Method Summary collapse

Methods inherited from Base

#db_client, #get, #initialize, #post

Constructor Details

This class inherits a constructor from Ucenter::Interface::Base

Instance Method Details

#check_login(username, password, is_uid = FALSE) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/ucenter/interface/user.rb', line 18

def (username, password, is_uid = FALSE)
  user = get_user(username, is_uid)
  if user['username'].nil?
    return [-1,nil]
  elsif user['password'] != md5("#{md5(password)}#{user['salt']}")
    return [-2,nil]
  end
  [user['uid'],user]
end

#get_user(username, is_uid = FALSE) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ucenter/interface/user.rb', line 5

def get_user(username, is_uid = FALSE)
  if is_uid == 1
    data = get_user_by_uid(username)
  elsif is_uid == 2
    data= get_user_by_email(username)
  elsif is_uid == 3
    data = get_user_by_phone(username)
  else
    data = get_user_by_username(username)
  end
  data
end