Description:
fixed new users import bug when passwords contain extra spaces at the end
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r307:2cdefa1ab6f2 - - 1 file changed: 1 inserted, 1 deleted
@@ -25,97 +25,97 | |||
|
25 | 25 | @paginated = true |
|
26 | 26 | end |
|
27 | 27 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
28 | 28 | @contests = Contest.enabled |
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | def active |
|
32 | 32 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
33 | 33 | @users = [] |
|
34 | 34 | sessions.each do |session| |
|
35 | 35 | if session.data[:user_id] |
|
36 | 36 | @users << User.find(session.data[:user_id]) |
|
37 | 37 | end |
|
38 | 38 | end |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def show |
|
42 | 42 | @user = User.find(params[:id]) |
|
43 | 43 | end |
|
44 | 44 | |
|
45 | 45 | def new |
|
46 | 46 | @user = User.new |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def create |
|
50 | 50 | @user = User.new(params[:user]) |
|
51 | 51 | @user.activated = true |
|
52 | 52 | if @user.save |
|
53 | 53 | flash[:notice] = 'User was successfully created.' |
|
54 | 54 | redirect_to :action => 'list' |
|
55 | 55 | else |
|
56 | 56 | render :action => 'new' |
|
57 | 57 | end |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def create_from_list |
|
61 | 61 | lines = params[:user_list] |
|
62 | 62 | |
|
63 | 63 | note = [] |
|
64 | 64 | |
|
65 | 65 | lines.split("\n").each do |line| |
|
66 | 66 | items = line.chomp.split(',') |
|
67 | 67 | if items.length>=2 |
|
68 | 68 | login = items[0] |
|
69 | 69 | full_name = items[1] |
|
70 | 70 | |
|
71 | 71 | added_random_password = false |
|
72 | 72 | if items.length>=3 |
|
73 | - password = items[2] | |
|
73 | + password = items[2].chomp(" ") | |
|
74 | 74 | user_alias = (items.length>=4) ? items[3] : login |
|
75 | 75 | else |
|
76 | 76 | password = random_password |
|
77 | 77 | user_alias = (items.length>=4) ? items[3] : login |
|
78 | 78 | added_random_password = true |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | user = User.new({:login => login, |
|
82 | 82 | :full_name => full_name, |
|
83 | 83 | :password => password, |
|
84 | 84 | :password_confirmation => password, |
|
85 | 85 | :alias => user_alias}) |
|
86 | 86 | user.activated = true |
|
87 | 87 | user.save |
|
88 | 88 | |
|
89 | 89 | if added_random_password |
|
90 | 90 | note << "'#{login}' (+)" |
|
91 | 91 | else |
|
92 | 92 | note << login |
|
93 | 93 | end |
|
94 | 94 | end |
|
95 | 95 | end |
|
96 | 96 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
97 | 97 | ' were successfully created. ' + |
|
98 | 98 | '( (+) - created with random passwords.)' |
|
99 | 99 | redirect_to :action => 'list' |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def edit |
|
103 | 103 | @user = User.find(params[:id]) |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | def update |
|
107 | 107 | @user = User.find(params[:id]) |
|
108 | 108 | if @user.update_attributes(params[:user]) |
|
109 | 109 | flash[:notice] = 'User was successfully updated.' |
|
110 | 110 | redirect_to :action => 'show', :id => @user |
|
111 | 111 | else |
|
112 | 112 | render :action => 'edit' |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | def destroy |
|
117 | 117 | User.find(params[:id]).destroy |
|
118 | 118 | redirect_to :action => 'list' |
|
119 | 119 | end |
|
120 | 120 | |
|
121 | 121 | def user_stat |
You need to be logged in to leave comments.
Login now