... | ... |
@@ -1,18 +1,15 @@ |
1 | 1 |
class ApplicationController < ActionController::Base |
2 |
- #protect_from_forgery |
|
3 | 2 |
|
4 |
- #before_filter :require_login |
|
3 |
+ before_filter :require_login |
|
5 | 4 |
|
6 | 5 |
def require_login |
7 |
- #if controller_name == 'sessions' && action_name == 'new' |
|
8 |
- # true |
|
9 |
- #end |
|
10 |
- |
|
11 | 6 |
if authenticated? |
12 | 7 |
create_new_authentification() |
13 | 8 |
else |
14 |
- #create_new_authentification() |
|
15 |
- #Redirect to login page |
|
9 |
+ unless controller_name == 'sessions' && (action_name == 'new' || action_name == 'create') |
|
10 |
+ flash.now[:error] = I18n.t 'login.access-denied' |
|
11 |
+ render "sessions/new" |
|
12 |
+ end |
|
16 | 13 |
end |
17 | 14 |
end |
18 | 15 |
|
... | ... |
@@ -5,13 +5,11 @@ en: |
5 | 5 |
login: |
6 | 6 |
error: 'Invalid email/password combination' |
7 | 7 |
success: 'Successfully logged in' |
8 |
+ access-denied: 'Access denied. Please, sign in first.' |
|
8 | 9 |
|
9 | 10 |
sessions: |
10 | 11 |
title: "Login" |
11 | 12 |
|
12 | 13 |
new: |
13 | 14 |
form-header: "Login form" |
14 |
- form-send: "Login" |
|
15 |
- chat: |
|
16 |
- title: "Chat" |
|
17 |
- avatar_alt: "Your avatar" |
|
18 | 15 |
\ No newline at end of file |
16 |
+ form-send: "Login" |
|
19 | 17 |
\ No newline at end of file |