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

#add_userObject



56
57
58
# File 'lib/ucenter/interface/user.rb', line 56

def add_user
  # TODO: 注册
end

#check_email_access(email) ⇒ Object



39
40
41
42
# File 'lib/ucenter/interface/user.rb', line 39

def check_email_access(email)
  # TODO: 验证email权限
  TRUE
end

#check_email_exist(email, username = '') ⇒ Object



44
45
46
47
48
49
# File 'lib/ucenter/interface/user.rb', line 44

def check_email_exist(email, username = '')
  username = db_client.escape(username)
  email = db_client.escape(email)
  sql_add = username != '' ? "AND username<>'#{username}'" : '';
  db_client.query("SELECT email FROM  #{Ucenter::Config.uc_dbtablepre}members WHERE email='#{email}' #{sql_add}").to_a[0]
end

#check_email_format(email) ⇒ Object



35
36
37
# File 'lib/ucenter/interface/user.rb', line 35

def check_email_format(email)
  email.bytesize > 6 and !(/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/ =~ email).nil?
end

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



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

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

#check_mergeuser(username) ⇒ Object



51
52
53
54
# File 'lib/ucenter/interface/user.rb', line 51

def check_mergeuser(username)
  username = db_client.escape(username)
  db_client.query("SELECT count(*) FROM #{Ucenter::Config.uc_dbtablepre}mergemembers WHERE appid='#{Ucenter::Config.app_id}' AND username='#{username}'").to_a[0]
end

#check_username(username) ⇒ Object



29
30
31
32
33
# File 'lib/ucenter/interface/user.rb', line 29

def check_username(username)
  len = username.bytesize
  return FALSE if len > 15 or len < 3 or !( /\s+|^c:\\con\\con|\[%,\*\"\s\<\>\&\]|\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8/is =~ username).nil?
  TRUE
end

#delete_userObject



64
65
66
# File 'lib/ucenter/interface/user.rb', line 64

def delete_user
  # TODO: 删除
end

#edit_userObject



60
61
62
# File 'lib/ucenter/interface/user.rb', line 60

def edit_user
  # TODO: 修改
end

#get_user(username, is_uid = FALSE) ⇒ Object



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

def get_user(username, is_uid = FALSE)
  username = db_client.escape(username) unless username.nil?
  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