Description:
add license agreement checkbox
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r535:a0fe4acdb4ed - - 3 files changed: 10 inserted, 2 deleted

@@ -1,34 +1,37
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 def index
3 def index
4 # show login screen
4 # show login screen
5 reset_session
5 reset_session
6 redirect_to :controller => 'main', :action => 'login'
6 redirect_to :controller => 'main', :action => 'login'
7 end
7 end
8
8
9 def login
9 def login
10 - if user = User.authenticate(params[:login], params[:password])
10 + if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree])
11 + flash[:notice] = 'You must accept the agreement before logging in'
12 + redirect_to :controller => 'main', :action => 'login'
13 + elsif user = User.authenticate(params[:login], params[:password])
11 session[:user_id] = user.id
14 session[:user_id] = user.id
12 session[:admin] = user.admin?
15 session[:admin] = user.admin?
13
16
14 # clear forced logout flag for multicontests contest change
17 # clear forced logout flag for multicontests contest change
15 if GraderConfiguration.multicontests?
18 if GraderConfiguration.multicontests?
16 contest_stat = user.contest_stat
19 contest_stat = user.contest_stat
17 if contest_stat.respond_to? :forced_logout
20 if contest_stat.respond_to? :forced_logout
18 if contest_stat.forced_logout
21 if contest_stat.forced_logout
19 contest_stat.forced_logout = false
22 contest_stat.forced_logout = false
20 contest_stat.save
23 contest_stat.save
21 end
24 end
22 end
25 end
23 end
26 end
24
27
25 #save login information
28 #save login information
26 Login.create(user_id: user.id, ip_address: request.remote_ip)
29 Login.create(user_id: user.id, ip_address: request.remote_ip)
27
30
28 redirect_to :controller => 'main', :action => 'list'
31 redirect_to :controller => 'main', :action => 'list'
29 else
32 else
30 flash[:notice] = 'Wrong password'
33 flash[:notice] = 'Wrong password'
31 redirect_to :controller => 'main', :action => 'login'
34 redirect_to :controller => 'main', :action => 'login'
32 end
35 end
33 end
36 end
34
37
@@ -1,34 +1,39
1 %b= GraderConfiguration['ui.front.welcome_message']
1 %b= GraderConfiguration['ui.front.welcome_message']
2 %br/
2 %br/
3
3
4 - if !@hidelogin
4 - if !@hidelogin
5 =t 'login.message'
5 =t 'login.message'
6 %br/
6 %br/
7 %br/
7 %br/
8
8
9 - if flash[:notice]
9 - if flash[:notice]
10 %hr/
10 %hr/
11 %b= flash[:notice]
11 %b= flash[:notice]
12 %hr/
12 %hr/
13
13
14 %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
14 %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
15 = form_tag :controller => 'login', :action => 'login' do
15 = form_tag :controller => 'login', :action => 'login' do
16 %table
16 %table
17 %tr
17 %tr
18 %td{:align => "right"}
18 %td{:align => "right"}
19 ="#{t 'login_label'}:"
19 ="#{t 'login_label'}:"
20 %td= text_field_tag 'login'
20 %td= text_field_tag 'login'
21 %tr
21 %tr
22 %td{:align => "right"}
22 %td{:align => "right"}
23 ="#{t 'password_label'}:"
23 ="#{t 'password_label'}:"
24 %td= password_field_tag
24 %td= password_field_tag
25 + - unless GraderConfiguration['right.bypass_agreement']
26 + %tr
27 + %td{:align => "right"}= check_box_tag 'accept_agree'
28 + %td ΰΈ’ΰΈ­ΰΈ‘ΰΈ£ΰΈ±ΰΈšΰΈ‚ΰΉ‰ΰΈ­ΰΈ•ΰΈΰΈ₯ΰΈ‡ΰΈΰΈ²ΰΈ£ΰΉƒΰΈŠΰΉ‰ΰΈ‡ΰΈ²ΰΈ™
29 +
25 = submit_tag t('login.login_submit')
30 = submit_tag t('login.login_submit')
26 %br/
31 %br/
27
32
28 - if GraderConfiguration['system.online_registration']
33 - if GraderConfiguration['system.online_registration']
29 =t 'login.participation'
34 =t 'login.participation'
30 %b
35 %b
31 = "#{t 'login.please'} "
36 = "#{t 'login.please'} "
32 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
37 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
33 %br/
38 %br/
34 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
39 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
@@ -1,38 +1,38
1 # encoding: UTF-8
1 # encoding: UTF-8
2 # This file is auto-generated from the current state of the database. Instead
2 # This file is auto-generated from the current state of the database. Instead
3 # of editing this file, please use the migrations feature of Active Record to
3 # of editing this file, please use the migrations feature of Active Record to
4 # incrementally modify your database, and then regenerate this schema definition.
4 # incrementally modify your database, and then regenerate this schema definition.
5 #
5 #
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 # It's strongly recommended to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(:version => 20150914155101) do
14 + ActiveRecord::Schema.define(:version => 20150914223258) do
15
15
16 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
17 t.string "author"
17 t.string "author"
18 t.text "body", :limit => 16777215
18 t.text "body", :limit => 16777215
19 t.boolean "published"
19 t.boolean "published"
20 t.datetime "created_at", :null => false
20 t.datetime "created_at", :null => false
21 t.datetime "updated_at", :null => false
21 t.datetime "updated_at", :null => false
22 t.boolean "frontpage", :default => false
22 t.boolean "frontpage", :default => false
23 t.boolean "contest_only", :default => false
23 t.boolean "contest_only", :default => false
24 t.string "title"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 create_table "contests", :force => true do |t|
28 create_table "contests", :force => true do |t|
29 t.string "title"
29 t.string "title"
30 t.boolean "enabled"
30 t.boolean "enabled"
31 t.datetime "created_at", :null => false
31 t.datetime "created_at", :null => false
32 t.datetime "updated_at", :null => false
32 t.datetime "updated_at", :null => false
33 t.string "name"
33 t.string "name"
34 end
34 end
35
35
36 create_table "contests_problems", :id => false, :force => true do |t|
36 create_table "contests_problems", :id => false, :force => true do |t|
37 t.integer "contest_id"
37 t.integer "contest_id"
38 t.integer "problem_id"
38 t.integer "problem_id"
You need to be logged in to leave comments. Login now