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
@@ -49,49 +49,49 | |||||
|
49 | def create |
|
49 | def create |
|
50 | @user = User.new(params[:user]) |
|
50 | @user = User.new(params[:user]) |
|
51 | @user.activated = true |
|
51 | @user.activated = true |
|
52 | if @user.save |
|
52 | if @user.save |
|
53 | flash[:notice] = 'User was successfully created.' |
|
53 | flash[:notice] = 'User was successfully created.' |
|
54 | redirect_to :action => 'list' |
|
54 | redirect_to :action => 'list' |
|
55 | else |
|
55 | else |
|
56 | render :action => 'new' |
|
56 | render :action => 'new' |
|
57 | end |
|
57 | end |
|
58 | end |
|
58 | end |
|
59 |
|
59 | ||
|
60 | def create_from_list |
|
60 | def create_from_list |
|
61 | lines = params[:user_list] |
|
61 | lines = params[:user_list] |
|
62 |
|
62 | ||
|
63 | note = [] |
|
63 | note = [] |
|
64 |
|
64 | ||
|
65 | lines.split("\n").each do |line| |
|
65 | lines.split("\n").each do |line| |
|
66 | items = line.chomp.split(',') |
|
66 | items = line.chomp.split(',') |
|
67 | if items.length>=2 |
|
67 | if items.length>=2 |
|
68 | login = items[0] |
|
68 | login = items[0] |
|
69 | full_name = items[1] |
|
69 | full_name = items[1] |
|
70 |
|
70 | ||
|
71 | added_random_password = false |
|
71 | added_random_password = false |
|
72 | if items.length>=3 |
|
72 | if items.length>=3 |
|
73 | - password = items[2] |
|
73 | + password = items[2].chomp(" ") |
|
74 | user_alias = (items.length>=4) ? items[3] : login |
|
74 | user_alias = (items.length>=4) ? items[3] : login |
|
75 | else |
|
75 | else |
|
76 | password = random_password |
|
76 | password = random_password |
|
77 | user_alias = (items.length>=4) ? items[3] : login |
|
77 | user_alias = (items.length>=4) ? items[3] : login |
|
78 | added_random_password = true |
|
78 | added_random_password = true |
|
79 | end |
|
79 | end |
|
80 |
|
80 | ||
|
81 | user = User.new({:login => login, |
|
81 | user = User.new({:login => login, |
|
82 | :full_name => full_name, |
|
82 | :full_name => full_name, |
|
83 | :password => password, |
|
83 | :password => password, |
|
84 | :password_confirmation => password, |
|
84 | :password_confirmation => password, |
|
85 | :alias => user_alias}) |
|
85 | :alias => user_alias}) |
|
86 | user.activated = true |
|
86 | user.activated = true |
|
87 | user.save |
|
87 | user.save |
|
88 |
|
88 | ||
|
89 | if added_random_password |
|
89 | if added_random_password |
|
90 | note << "'#{login}' (+)" |
|
90 | note << "'#{login}' (+)" |
|
91 | else |
|
91 | else |
|
92 | note << login |
|
92 | note << login |
|
93 | end |
|
93 | end |
|
94 | end |
|
94 | end |
|
95 | end |
|
95 | end |
|
96 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
96 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
97 | ' were successfully created. ' + |
|
97 | ' were successfully created. ' + |
You need to be logged in to leave comments.
Login now