Description:
fix authen pop3 bugs and redundant code
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r406:b2fd7182e3dc - - 1 file changed: 3 inserted, 14 deleted
@@ -1,8 +1,10 | |||||
|
1 | require 'digest/sha1' |
|
1 | require 'digest/sha1' |
|
2 | require 'net/pop' |
|
2 | require 'net/pop' |
|
|
3 | + require 'net/https' | ||
|
|
4 | + require 'net/http' | ||
|
3 | require 'json' |
|
5 | require 'json' |
|
4 |
|
6 | ||
|
5 | class User < ActiveRecord::Base |
|
7 | class User < ActiveRecord::Base |
|
6 |
|
8 | ||
|
7 | has_and_belongs_to_many :roles |
|
9 | has_and_belongs_to_many :roles |
|
8 |
|
10 | ||
@@ -78,26 +80,13 | |||||
|
78 | hashed_password == User.encrypt(password,self.salt) |
|
80 | hashed_password == User.encrypt(password,self.salt) |
|
79 | else |
|
81 | else |
|
80 | false |
|
82 | false |
|
81 | end |
|
83 | end |
|
82 | end |
|
84 | end |
|
83 |
|
85 | ||
|
84 |
- def authenticated_by_pop3?(password) |
|
86 | + def authenticated_by_pop3?(password) |
|
85 | - Net::POP3.enable_ssl |
|
||
|
86 | - pop = Net::POP3.new('pops.it.chula.ac.th') |
|
||
|
87 | - authen = true |
|
||
|
88 | - begin |
|
||
|
89 | - pop.start(login, password) # (1) |
|
||
|
90 | - pop.finish |
|
||
|
91 | - return true |
|
||
|
92 | - rescue |
|
||
|
93 | - return false |
|
||
|
94 | - end |
|
||
|
95 | - end |
|
||
|
96 | - |
|
||
|
97 | - def authenticated_by_pop3?(password) |
|
||
|
98 | Net::POP3.enable_ssl |
|
87 | Net::POP3.enable_ssl |
|
99 | pop = Net::POP3.new('pops.it.chula.ac.th') |
|
88 | pop = Net::POP3.new('pops.it.chula.ac.th') |
|
100 | authen = true |
|
89 | authen = true |
|
101 | begin |
|
90 | begin |
|
102 | pop.start(login, password) |
|
91 | pop.start(login, password) |
|
103 | pop.finish |
|
92 | pop.finish |
You need to be logged in to leave comments.
Login now