@@ -42,6 +42,11 class AccountController < ApplicationController | |||
|
42 | 42 | user = User.try_to_login(params[:login], params[:password]) |
|
43 | 43 | if user |
|
44 | 44 | self.logged_in_user = user |
|
45 | # generate a key and set cookie if autologin | |
|
46 | if params[:autologin] && Setting.autologin? | |
|
47 | token = Token.create(:user => user, :action => 'autologin') | |
|
48 | cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now } | |
|
49 | end | |
|
45 | 50 | redirect_back_or_default :controller => 'my', :action => 'page' |
|
46 | 51 | else |
|
47 | 52 | flash.now[:notice] = l(:notice_account_invalid_creditentials) |
@@ -51,6 +56,8 class AccountController < ApplicationController | |||
|
51 | 56 | |
|
52 | 57 | # Log out current user and redirect to welcome page |
|
53 | 58 | def logout |
|
59 | cookies.delete :autologin | |
|
60 | Token.delete_all(["user_id = ? AND action = ?", logged_in_user.id, "autologin"]) if logged_in_user | |
|
54 | 61 | self.logged_in_user = nil |
|
55 | 62 | redirect_to :controller => 'welcome' |
|
56 | 63 | end |
@@ -40,6 +40,13 class ApplicationController < ActionController::Base | |||
|
40 | 40 | |
|
41 | 41 | # check if login is globally required to access the application |
|
42 | 42 | def check_if_login_required |
|
43 | # no check needed if user is already logged in | |
|
44 | return true if logged_in_user | |
|
45 | # auto-login feature | |
|
46 | autologin_key = cookies[:autologin] | |
|
47 | if autologin_key && Setting.autologin? | |
|
48 | self.logged_in_user = User.find_by_autologin_key(autologin_key) | |
|
49 | end | |
|
43 | 50 | require_login if Setting.login_required? |
|
44 | 51 | end |
|
45 | 52 |
@@ -49,7 +49,7 class Setting < ActiveRecord::Base | |||
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def self.#{name}? |
|
52 |
self[:#{name}].to_ |
|
|
52 | self[:#{name}].to_i > 0 | |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | def self.#{name}=(value) |
@@ -141,6 +141,11 class User < ActiveRecord::Base | |||
|
141 | 141 | token = Token.find_by_value(key) |
|
142 | 142 | token && token.user.active? ? token.user : nil |
|
143 | 143 | end |
|
144 | ||
|
145 | def self.find_by_autologin_key(key) | |
|
146 | token = Token.find_by_action_and_value('autologin', key) | |
|
147 | token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil | |
|
148 | end | |
|
144 | 149 | |
|
145 | 150 | def <=>(user) |
|
146 | 151 | lastname == user.lastname ? firstname <=> user.firstname : lastname <=> user.lastname |
@@ -3,23 +3,26 | |||
|
3 | 3 | <h2 class="icon22 icon22-authent"><%=l(:label_please_login)%></h2> |
|
4 | 4 | |
|
5 | 5 | <% form_tag({:action=> "login"}, :class => "tabular") do %> |
|
6 | ||
|
6 | 7 | <p><label for="login"><%=l(:field_login)%>:</label> |
|
7 | 8 | <%= text_field_tag 'login', nil, :size => 25 %></p> |
|
8 | 9 | |
|
9 | 10 | <p><label for="password"><%=l(:field_password)%>:</label> |
|
10 | 11 | <%= password_field_tag 'password', nil, :size => 25 %></p> |
|
11 | 12 | |
|
12 | <p><center><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></center> | |
|
13 | <% if Setting.autologin? %> | |
|
14 | <p><label for="autologin"><%= check_box_tag 'autologin' %> <%= l(:label_stay_logged_in) %></label></p> | |
|
15 | <% end %> | |
|
16 | ||
|
17 | <p><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></p> | |
|
13 | 18 | <% end %> |
|
14 | 19 | <%= javascript_tag "Form.Element.focus('login');" %> |
|
15 | 20 | |
|
16 | <br> | |
|
17 | 21 | <% links = [] |
|
18 | 22 | links << link_to(l(:label_register), :action => 'register') if Setting.self_registration? |
|
19 | 23 | links << link_to(l(:label_password_lost), :action => 'lost_password') if Setting.lost_password? |
|
20 | 24 | %> |
|
21 | 25 | <%= links.join(" | ") %> |
|
22 | </p> | |
|
23 | 26 | |
|
24 | 27 | </div> |
|
25 | 28 | </center> No newline at end of file |
@@ -15,15 +15,6 | |||
|
15 | 15 | <p><label><%= l(:setting_default_language) %></label> |
|
16 | 16 | <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p> |
|
17 | 17 | |
|
18 | <p><label><%= l(:setting_login_required) %></label> | |
|
19 | <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> | |
|
20 | ||
|
21 | <p><label><%= l(:setting_self_registration) %></label> | |
|
22 | <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p> | |
|
23 | ||
|
24 | <p><label><%= l(:label_password_lost) %></label> | |
|
25 | <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p> | |
|
26 | ||
|
27 | 18 | <p><label><%= l(:setting_attachment_max_size) %></label> |
|
28 | 19 | <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p> |
|
29 | 20 | |
@@ -52,6 +43,20 | |||
|
52 | 43 | <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p> |
|
53 | 44 | </div> |
|
54 | 45 | |
|
46 | <fieldset class="box"><legend><%= l(:label_authentication) %></legend> | |
|
47 | <p><label><%= l(:setting_login_required) %></label> | |
|
48 | <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> | |
|
49 | ||
|
50 | <p><label><%= l(:setting_autologin) %></label> | |
|
51 | <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p> | |
|
52 | ||
|
53 | <p><label><%= l(:setting_self_registration) %></label> | |
|
54 | <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p> | |
|
55 | ||
|
56 | <p><label><%= l(:label_password_lost) %></label> | |
|
57 | <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p> | |
|
58 | </fieldset> | |
|
59 | ||
|
55 | 60 | <fieldset class="box"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend> |
|
56 | 61 | <p><label><%= l(:setting_commit_ref_keywords) %></label> |
|
57 | 62 | <%= text_field_tag 'settings[commit_ref_keywords]', Setting.commit_ref_keywords, :size => 30 %><br /><em><%= l(:text_coma_separated) %></em></p> |
@@ -61,4 +61,8 commit_fix_keywords: | |||
|
61 | 61 | commit_fix_status_id: |
|
62 | 62 | format: int |
|
63 | 63 | default: 0 |
|
64 | No newline at end of file | |
|
64 | # autologin duration in days | |
|
65 | # 0 means autologin is disabled | |
|
66 | autologin: | |
|
67 | format: int | |
|
68 | default: 0 |
@@ -171,6 +171,7 setting_autofetch_changesets: Автоматично обработване на | |||
|
171 | 171 | setting_sys_api_enabled: Разрешаване на WS за управление на SVN склада |
|
172 | 172 | setting_commit_ref_keywords: Отбелязващи ключови думи |
|
173 | 173 | setting_commit_fix_keywords: Приключващи ключови думи |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Потребител |
|
176 | 177 | label_user_plural: Потребители |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Вход |
|
385 | 388 | button_submit: Изпращане |
@@ -171,6 +171,7 setting_autofetch_changesets: Autofetch SVN commits | |||
|
171 | 171 | setting_sys_api_enabled: Enable WS for repository management |
|
172 | 172 | setting_commit_ref_keywords: Referencing keywords |
|
173 | 173 | setting_commit_fix_keywords: Fixing keywords |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Benutzer |
|
176 | 177 | label_user_plural: Benutzer |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Einloggen |
|
385 | 388 | button_submit: OK |
@@ -171,6 +171,7 setting_autofetch_changesets: Autofetch SVN commits | |||
|
171 | 171 | setting_sys_api_enabled: Enable WS for repository management |
|
172 | 172 | setting_commit_ref_keywords: Referencing keywords |
|
173 | 173 | setting_commit_fix_keywords: Fixing keywords |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: User |
|
176 | 177 | label_user_plural: Users |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Login |
|
385 | 388 | button_submit: Submit |
@@ -171,6 +171,7 setting_autofetch_changesets: Autofetch SVN commits | |||
|
171 | 171 | setting_sys_api_enabled: Enable WS for repository management |
|
172 | 172 | setting_commit_ref_keywords: Referencing keywords |
|
173 | 173 | setting_commit_fix_keywords: Fixing keywords |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Usuario |
|
176 | 177 | label_user_plural: Usuarios |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Conexión |
|
385 | 388 | button_submit: Someter |
@@ -171,6 +171,7 setting_autofetch_changesets: Récupération auto. des commits SVN | |||
|
171 | 171 | setting_sys_api_enabled: Activer les WS pour la gestion des dépôts |
|
172 | 172 | setting_commit_ref_keywords: Mot-clés de référencement |
|
173 | 173 | setting_commit_fix_keywords: Mot-clés de résolution |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Utilisateur |
|
176 | 177 | label_user_plural: Utilisateurs |
@@ -380,6 +381,8 label_end_to_start: début à fin | |||
|
380 | 381 | label_end_to_end: fin à fin |
|
381 | 382 | label_start_to_start: début à début |
|
382 | 383 | label_start_to_end: début à fin |
|
384 | label_stay_logged_in: Rester connecté | |
|
385 | label_disabled: désactivé | |
|
383 | 386 | |
|
384 | 387 | button_login: Connexion |
|
385 | 388 | button_submit: Soumettre |
@@ -171,6 +171,7 setting_autofetch_changesets: Acquisisci automaticamente le commit SVN | |||
|
171 | 171 | setting_sys_api_enabled: Abilita WS per la gestione del repository |
|
172 | 172 | setting_commit_ref_keywords: Referencing keywords |
|
173 | 173 | setting_commit_fix_keywords: Fixing keywords |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Utente |
|
176 | 177 | label_user_plural: Utenti |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Login |
|
385 | 388 | button_submit: Invia |
@@ -172,6 +172,7 setting_autofetch_changesets: SVNコミットを自動取得する | |||
|
172 | 172 | setting_sys_api_enabled: リポジトリ管理用のWeb Serviceを有効化する |
|
173 | 173 | setting_commit_ref_keywords: Referencing keywords |
|
174 | 174 | setting_commit_fix_keywords: Fixing keywords |
|
175 | setting_autologin: Autologin | |
|
175 | 176 | |
|
176 | 177 | label_user: ユーザ |
|
177 | 178 | label_user_plural: ユーザ |
@@ -381,6 +382,8 label_end_to_start: start to end | |||
|
381 | 382 | label_end_to_end: end to end |
|
382 | 383 | label_start_to_start: start to start |
|
383 | 384 | label_start_to_end: start to end |
|
385 | label_stay_logged_in: Stay logged in | |
|
386 | label_disabled: disabled | |
|
384 | 387 | |
|
385 | 388 | button_login: ログイン |
|
386 | 389 | button_submit: 変更 |
@@ -171,6 +171,7 setting_autofetch_changesets: Autofetch SVN commits | |||
|
171 | 171 | setting_sys_api_enabled: Ativa WS para gerenciamento do repositorio |
|
172 | 172 | setting_commit_ref_keywords: Referencing keywords |
|
173 | 173 | setting_commit_fix_keywords: Fixing keywords |
|
174 | setting_autologin: Autologin | |
|
174 | 175 | |
|
175 | 176 | label_user: Usuario |
|
176 | 177 | label_user_plural: Usuarios |
@@ -380,6 +381,8 label_end_to_start: start to end | |||
|
380 | 381 | label_end_to_end: end to end |
|
381 | 382 | label_start_to_start: start to start |
|
382 | 383 | label_start_to_end: start to end |
|
384 | label_stay_logged_in: Stay logged in | |
|
385 | label_disabled: disabled | |
|
383 | 386 | |
|
384 | 387 | button_login: Login |
|
385 | 388 | button_submit: Enviar |
@@ -174,6 +174,7 setting_autofetch_changesets: Autofetch SVN commits | |||
|
174 | 174 | setting_sys_api_enabled: Enable WS for repository management |
|
175 | 175 | setting_commit_ref_keywords: Referencing keywords |
|
176 | 176 | setting_commit_fix_keywords: Fixing keywords |
|
177 | setting_autologin: Autologin | |
|
177 | 178 | |
|
178 | 179 | label_user: 用户 |
|
179 | 180 | label_user_plural: 用户列表 |
@@ -383,6 +384,8 label_end_to_start: start to end | |||
|
383 | 384 | label_end_to_end: end to end |
|
384 | 385 | label_start_to_start: start to start |
|
385 | 386 | label_start_to_end: start to end |
|
387 | label_stay_logged_in: Stay logged in | |
|
388 | label_disabled: disabled | |
|
386 | 389 | |
|
387 | 390 | button_login: 登录 |
|
388 | 391 | button_submit: 提交 |
General Comments 0
You need to be logged in to leave comments.
Login now