Description:
NEED TESTING
move to stronger parameter for xxx.new(params[
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r637:d56b2e7de528 - - 4 files changed: 10 inserted, 6 deleted
@@ -42,13 +42,13 | |||
|
42 | 42 | @announcement = Announcement.find(params[:id]) |
|
43 | 43 | end |
|
44 | 44 | |
|
45 | 45 | # POST /announcements |
|
46 | 46 | # POST /announcements.xml |
|
47 | 47 | def create |
|
48 |
- @announcement = Announcement.new( |
|
|
48 | + @announcement = Announcement.new(announcement_params) | |
|
49 | 49 | |
|
50 | 50 | respond_to do |format| |
|
51 | 51 | if @announcement.save |
|
52 | 52 | flash[:notice] = 'Announcement was successfully created.' |
|
53 | 53 | format.html { redirect_to(@announcement) } |
|
54 | 54 | format.xml { render :xml => @announcement, :status => :created, :location => @announcement } |
@@ -25,13 +25,13 | |||
|
25 | 25 | def new |
|
26 | 26 | @problem = Problem.new |
|
27 | 27 | @description = nil |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | 30 | def create |
|
31 |
- @problem = Problem.new( |
|
|
31 | + @problem = Problem.new(problem_params) | |
|
32 | 32 | @description = Description.new(params[:description]) |
|
33 | 33 | if @description.body!='' |
|
34 | 34 | if !@description.save |
|
35 | 35 | render :action => new and return |
|
36 | 36 | end |
|
37 | 37 | else |
@@ -44,13 +44,13 | |||
|
44 | 44 | else |
|
45 | 45 | render :action => 'new' |
|
46 | 46 | end |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def quick_create |
|
50 |
- @problem = Problem.new( |
|
|
50 | + @problem = Problem.new(problem_params) | |
|
51 | 51 | @problem.full_name = @problem.name if @problem.full_name == '' |
|
52 | 52 | @problem.full_score = 100 |
|
53 | 53 | @problem.available = false |
|
54 | 54 | @problem.test_allowed = true |
|
55 | 55 | @problem.output_only = false |
|
56 | 56 | @problem.date_added = Time.new |
@@ -44,13 +44,13 | |||
|
44 | 44 | |
|
45 | 45 | def new |
|
46 | 46 | @user = User.new |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def create |
|
50 |
- @user = User.new(params |
|
|
50 | + @user = User.new(user_params) | |
|
51 | 51 | @user.activated = true |
|
52 | 52 | if @user.save |
|
53 | 53 | flash[:notice] = 'User was successfully created.' |
|
54 | 54 | redirect_to :action => 'index' |
|
55 | 55 | else |
|
56 | 56 | render :action => 'new' |
@@ -49,13 +49,13 | |||
|
49 | 49 | |
|
50 | 50 | def register |
|
51 | 51 | if(params[:cancel]) |
|
52 | 52 | redirect_to :controller => 'main', :action => 'login' |
|
53 | 53 | return |
|
54 | 54 | end |
|
55 |
- @user = User.new(params |
|
|
55 | + @user = User.new(user_params) | |
|
56 | 56 | @user.password_confirmation = @user.password = User.random_password |
|
57 | 57 | @user.activated = false |
|
58 | 58 | if (@user.valid?) and (@user.save) |
|
59 | 59 | if send_confirmation_email(@user) |
|
60 | 60 | render :action => 'new_splash', :layout => 'empty' |
|
61 | 61 | else |
@@ -206,9 +206,13 | |||
|
206 | 206 | return admin_authorization if user.admin? |
|
207 | 207 | return true if GraderConfiguration["right.user_view_submission"] |
|
208 | 208 | |
|
209 | 209 | #finally, we allow only admin |
|
210 | 210 | admin_authorization |
|
211 | 211 | end |
|
212 | - | |
|
212 | + | |
|
213 | + private | |
|
214 | + def user_params | |
|
215 | + params.require(:user).permit(:login, :full_name, :email) | |
|
216 | + end | |
|
213 | 217 | |
|
214 | 218 | end |
You need to be logged in to leave comments.
Login now