Description:
add license agreement checkbox
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r535:a0fe4acdb4ed - - 3 files changed: 10 inserted, 2 deleted
@@ -1,54 +1,57 | |||
|
1 | 1 | class LoginController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | def index |
|
4 | 4 | # show login screen |
|
5 | 5 | reset_session |
|
6 | 6 | redirect_to :controller => 'main', :action => 'login' |
|
7 | 7 | end |
|
8 | 8 | |
|
9 | 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 | 14 | session[:user_id] = user.id |
|
12 | 15 | session[:admin] = user.admin? |
|
13 | 16 | |
|
14 | 17 | # clear forced logout flag for multicontests contest change |
|
15 | 18 | if GraderConfiguration.multicontests? |
|
16 | 19 | contest_stat = user.contest_stat |
|
17 | 20 | if contest_stat.respond_to? :forced_logout |
|
18 | 21 | if contest_stat.forced_logout |
|
19 | 22 | contest_stat.forced_logout = false |
|
20 | 23 | contest_stat.save |
|
21 | 24 | end |
|
22 | 25 | end |
|
23 | 26 | end |
|
24 | 27 | |
|
25 | 28 | #save login information |
|
26 | 29 | Login.create(user_id: user.id, ip_address: request.remote_ip) |
|
27 | 30 | |
|
28 | 31 | redirect_to :controller => 'main', :action => 'list' |
|
29 | 32 | else |
|
30 | 33 | flash[:notice] = 'Wrong password' |
|
31 | 34 | redirect_to :controller => 'main', :action => 'login' |
|
32 | 35 | end |
|
33 | 36 | end |
|
34 | 37 | |
|
35 | 38 | def site_login |
|
36 | 39 | begin |
|
37 | 40 | site = Site.find(params[:login][:site_id]) |
|
38 | 41 | rescue ActiveRecord::RecordNotFound |
|
39 | 42 | site = nil |
|
40 | 43 | end |
|
41 | 44 | if site==nil |
|
42 | 45 | flash[:notice] = 'Wrong site' |
|
43 | 46 | redirect_to :controller => 'main', :action => 'login' and return |
|
44 | 47 | end |
|
45 | 48 | if (site.password) and (site.password == params[:login][:password]) |
|
46 | 49 | session[:site_id] = site.id |
|
47 | 50 | redirect_to :controller => 'site', :action => 'index' |
|
48 | 51 | else |
|
49 | 52 | flash[:notice] = 'Wrong site password' |
|
50 | 53 | redirect_to :controller => 'site', :action => 'login' |
|
51 | 54 | end |
|
52 | 55 | end |
|
53 | 56 | |
|
54 | 57 | end |
@@ -1,34 +1,39 | |||
|
1 | 1 | %b= GraderConfiguration['ui.front.welcome_message'] |
|
2 | 2 | %br/ |
|
3 | 3 | |
|
4 | 4 | - if !@hidelogin |
|
5 | 5 | =t 'login.message' |
|
6 | 6 | %br/ |
|
7 | 7 | %br/ |
|
8 | 8 | |
|
9 | 9 | - if flash[:notice] |
|
10 | 10 | %hr/ |
|
11 | 11 | %b= flash[:notice] |
|
12 | 12 | %hr/ |
|
13 | 13 | |
|
14 | 14 | %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"} |
|
15 | 15 | = form_tag :controller => 'login', :action => 'login' do |
|
16 | 16 | %table |
|
17 | 17 | %tr |
|
18 | 18 | %td{:align => "right"} |
|
19 | 19 | ="#{t 'login_label'}:" |
|
20 | 20 | %td= text_field_tag 'login' |
|
21 | 21 | %tr |
|
22 | 22 | %td{:align => "right"} |
|
23 | 23 | ="#{t 'password_label'}:" |
|
24 | 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 | 30 | = submit_tag t('login.login_submit') |
|
26 | 31 | %br/ |
|
27 | 32 | |
|
28 | 33 | - if GraderConfiguration['system.online_registration'] |
|
29 | 34 | =t 'login.participation' |
|
30 | 35 | %b |
|
31 | 36 | = "#{t 'login.please'} " |
|
32 | 37 | = link_to "#{t 'login.register'}", :controller => :users, :action => :new |
|
33 | 38 | %br/ |
|
34 | 39 | = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget |
@@ -1,62 +1,62 | |||
|
1 | 1 | # encoding: UTF-8 |
|
2 | 2 | # This file is auto-generated from the current state of the database. Instead |
|
3 | 3 | # of editing this file, please use the migrations feature of Active Record to |
|
4 | 4 | # incrementally modify your database, and then regenerate this schema definition. |
|
5 | 5 | # |
|
6 | 6 | # Note that this schema.rb definition is the authoritative source for your |
|
7 | 7 | # database schema. If you need to create the application database on another |
|
8 | 8 | # system, you should be using db:schema:load, not running all the migrations |
|
9 | 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
10 | 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended to check this file into your version control system. |
|
13 | 13 | |
|
14 |
- ActiveRecord::Schema.define(:version => 20150914 |
|
|
14 | + ActiveRecord::Schema.define(:version => 20150914223258) do | |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", :force => true do |t| |
|
17 | 17 | t.string "author" |
|
18 | 18 | t.text "body", :limit => 16777215 |
|
19 | 19 | t.boolean "published" |
|
20 | 20 | t.datetime "created_at", :null => false |
|
21 | 21 | t.datetime "updated_at", :null => false |
|
22 | 22 | t.boolean "frontpage", :default => false |
|
23 | 23 | t.boolean "contest_only", :default => false |
|
24 | 24 | t.string "title" |
|
25 | 25 | t.string "notes" |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", :force => true do |t| |
|
29 | 29 | t.string "title" |
|
30 | 30 | t.boolean "enabled" |
|
31 | 31 | t.datetime "created_at", :null => false |
|
32 | 32 | t.datetime "updated_at", :null => false |
|
33 | 33 | t.string "name" |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", :id => false, :force => true do |t| |
|
37 | 37 | t.integer "contest_id" |
|
38 | 38 | t.integer "problem_id" |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", :id => false, :force => true do |t| |
|
42 | 42 | t.integer "contest_id" |
|
43 | 43 | t.integer "user_id" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", :force => true do |t| |
|
47 | 47 | t.string "name" |
|
48 | 48 | t.datetime "created_at", :null => false |
|
49 | 49 | t.datetime "updated_at", :null => false |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", :force => true do |t| |
|
53 | 53 | t.text "body", :limit => 16777215 |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 | t.datetime "created_at", :null => false |
|
56 | 56 | t.datetime "updated_at", :null => false |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", :force => true do |t| |
|
60 | 60 | t.string "key" |
|
61 | 61 | t.string "value_type" |
|
62 | 62 | t.string "value" |
You need to be logged in to leave comments.
Login now