Description:
fix wrong merge on user
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r845:daf5f8de8a3f - - 1 file changed: 4 inserted, 0 deleted

@@ -67,48 +67,52
67 67 cattr_reader :per_page
68 68 @@per_page = 50
69 69
70 70 def self.authenticate(login, password)
71 71 user = find_by_login(login)
72 72 if user
73 73 return user if user.authenticated?(password)
74 74 if user.authenticated_by_cucas?(password)
75 75 user.password = password
76 76 user.save
77 77 return user
78 78 end
79 79 end
80 80 end
81 81
82 82
83 83 def authenticated?(password)
84 84 if self.activated
85 85 hashed_password == User.encrypt(password,self.salt)
86 86 else
87 87 false
88 88 end
89 89 end
90 90
91 + def login_with_name
92 + "[#{login}] #{full_name}"
93 + end
94 +
91 95 def authenticated_by_cucas?(password)
92 96 url = URI.parse('https://www.cas.chula.ac.th/cas/api/?q=studentAuthenticate')
93 97 appid = '41508763e340d5858c00f8c1a0f5a2bb'
94 98 appsecret ='d9cbb5863091dbe186fded85722a1e31'
95 99 post_args = {
96 100 'appid' => appid,
97 101 'appsecret' => appsecret,
98 102 'username' => login,
99 103 'password' => password
100 104 }
101 105
102 106 #simple call
103 107 begin
104 108 http = Net::HTTP.new('www.cas.chula.ac.th', 443)
105 109 http.use_ssl = true
106 110 http.verify_mode = OpenSSL::SSL::VERIFY_NONE
107 111 result = [ ]
108 112 http.start do |http|
109 113 req = Net::HTTP::Post.new('/cas/api/?q=studentAuthenticate')
110 114 #req = Net::HTTP::Post.new('/appX/prod/?q=studentAuthenticate')
111 115 #req = Net::HTTP::Post.new('/app2/prod/api/?q=studentAuthenticate')
112 116 param = "appid=#{appid}&appsecret=#{appsecret}&username=#{login}&password=#{password}"
113 117 resp = http.request(req,param)
114 118 result = JSON.parse resp.body
You need to be logged in to leave comments. Login now