Description:
hacked user creation to bypass member name validation, changed default config for test pair import
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r261:432c3e723bef - - 2 files changed: 2 inserted, 1 deleted
@@ -1,88 +1,89 | |||
|
1 | 1 | class UserAdminController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | before_filter :admin_authorization |
|
4 | 4 | |
|
5 | 5 | def index |
|
6 | 6 | list |
|
7 | 7 | render :action => 'list' |
|
8 | 8 | end |
|
9 | 9 | |
|
10 | 10 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
11 | 11 | verify :method => :post, :only => [ :destroy, |
|
12 | 12 | :create, :create_from_list, |
|
13 | 13 | :update ], |
|
14 | 14 | :redirect_to => { :action => :list } |
|
15 | 15 | |
|
16 | 16 | def list |
|
17 | 17 | @users = User.find(:all) |
|
18 | 18 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | def active |
|
22 | 22 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
23 | 23 | @users = [] |
|
24 | 24 | sessions.each do |session| |
|
25 | 25 | if session.data[:user_id] |
|
26 | 26 | @users << User.find(session.data[:user_id]) |
|
27 | 27 | end |
|
28 | 28 | end |
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | def show |
|
32 | 32 | @user = User.find(params[:id]) |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def new |
|
36 | 36 | @user = User.new |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def create |
|
40 | 40 | @user = User.new(params[:user]) |
|
41 | + @user.member1_full_name = @user.full_name | |
|
41 | 42 | @user.activated = true |
|
42 | 43 | if @user.save |
|
43 | 44 | flash[:notice] = 'User was successfully created.' |
|
44 | 45 | redirect_to :action => 'list' |
|
45 | 46 | else |
|
46 | 47 | render :action => 'new' |
|
47 | 48 | end |
|
48 | 49 | end |
|
49 | 50 | |
|
50 | 51 | def create_from_list |
|
51 | 52 | lines = params[:user_list] |
|
52 | 53 | |
|
53 | 54 | note = [] |
|
54 | 55 | |
|
55 | 56 | lines.split("\n").each do |line| |
|
56 | 57 | items = line.chomp.split(',') |
|
57 | 58 | if items.length>=2 |
|
58 | 59 | login = items[0] |
|
59 | 60 | full_name = items[1] |
|
60 | 61 | |
|
61 | 62 | added_random_password = false |
|
62 | 63 | if items.length>=3 |
|
63 | 64 | password = items[2] |
|
64 | 65 | user_alias = (items.length>=4) ? items[3] : login |
|
65 | 66 | else |
|
66 | 67 | password = random_password |
|
67 | 68 | user_alias = (items.length>=4) ? items[3] : login |
|
68 | 69 | added_random_password = true |
|
69 | 70 | end |
|
70 | 71 | |
|
71 | 72 | user = User.new({:login => login, |
|
72 | 73 | :full_name => full_name, |
|
73 | 74 | :password => password, |
|
74 | 75 | :password_confirmation => password, |
|
75 | 76 | :alias => user_alias}) |
|
76 | 77 | user.activated = true |
|
77 | 78 | user.save |
|
78 | 79 | |
|
79 | 80 | if added_random_password |
|
80 | 81 | note << "'#{login}' (+)" |
|
81 | 82 | else |
|
82 | 83 | note << login |
|
83 | 84 | end |
|
84 | 85 | end |
|
85 | 86 | end |
|
86 | 87 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
87 | 88 | ' were successfully created. ' + |
|
88 | 89 | '( (+) - created with random passwords.)' |
@@ -47,66 +47,66 | |||
|
47 | 47 | # See Rails::Configuration for more options |
|
48 | 48 | |
|
49 | 49 | # ------------- |
|
50 | 50 | # Required gems |
|
51 | 51 | # ------------- |
|
52 | 52 | config.gem "haml" |
|
53 | 53 | config.gem "tmail" |
|
54 | 54 | config.gem "rdiscount", :lib => "rdiscount" |
|
55 | 55 | |
|
56 | 56 | # NOTES on rspec: if you wan to test with rspec, you have to install |
|
57 | 57 | # rspec yourself, just call: [sudo] gem install rspec-rails |
|
58 | 58 | |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | # Add new inflection rules using the following format |
|
62 | 62 | # (all these examples are active by default): |
|
63 | 63 | # Inflector.inflections do |inflect| |
|
64 | 64 | # inflect.plural /^(ox)$/i, '\1en' |
|
65 | 65 | # inflect.singular /^(ox)en/i, '\1' |
|
66 | 66 | # inflect.irregular 'person', 'people' |
|
67 | 67 | # inflect.uncountable %w( fish sheep ) |
|
68 | 68 | # end |
|
69 | 69 | |
|
70 | 70 | # Add new mime types for use in respond_to blocks: |
|
71 | 71 | # Mime::Type.register "text/richtext", :rtf |
|
72 | 72 | # Mime::Type.register "application/x-mobile", :mobile |
|
73 | 73 | |
|
74 | 74 | # Include your application configuration below |
|
75 | 75 | |
|
76 | 76 | # If you want to manage graders through web interface, set the path to |
|
77 | 77 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
78 | 78 | # scripts reside. All grader scripts will be in |
|
79 | 79 | # #{GRADER_ROOT_DIR}/scripts. |
|
80 | 80 | GRADER_ROOT_DIR = '' |
|
81 | 81 | |
|
82 | 82 | # These are where inputs and outputs of test requests are stored |
|
83 | 83 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
84 | 84 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
85 | 85 | |
|
86 | 86 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
87 | 87 | # and the directory of the grading result (usually in judge's dir). |
|
88 | 88 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
89 | 89 | |
|
90 | 90 | # TODO: change this to where results are kept. |
|
91 | 91 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
92 | 92 | |
|
93 | 93 | # Change this to allow importing testdata into database as test-pairs. |
|
94 | 94 | # This is mainly for Code Jom contest. |
|
95 |
- ALLOW_TEST_PAIR_IMPORT = |
|
|
95 | + ALLOW_TEST_PAIR_IMPORT = true | |
|
96 | 96 | |
|
97 | 97 | # Uncomment so that the system validates user e-mails |
|
98 | 98 | # VALIDATE_USER_EMAILS = true |
|
99 | 99 | |
|
100 | 100 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
101 | 101 | # (e.g., in /tasks/view). |
|
102 | 102 | # USE_APACHE_XSENDFILE = true |
|
103 | 103 | |
|
104 | 104 | # Uncomment so that configuration is read only once when the server is loaded |
|
105 | 105 | # Configuration.enable_caching |
|
106 | 106 | |
|
107 | 107 | # OPTIONS FOR CODE JOM |
|
108 | 108 | # -------------------- |
|
109 | 109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
110 | 110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
111 | 111 | SHOW_CONTEST_STATUS = false |
|
112 | 112 | HIDE_PASSED_TASKS = true No newline at end of file |
You need to be logged in to leave comments.
Login now