Browse code

Nastavenie tokenov po uspesnom prihlaseni, fixy s prihlasovanim

Cinan Rakosnik authored on 25/02/2013 at 19:42:43
Showing 4 changed files
... ...
@@ -1,18 +1,15 @@
1 1
 class ApplicationController < ActionController::Base
2
-  #protect_from_forgery
3 2
 
4 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
 
... ...
@@ -13,6 +13,7 @@ class SessionsController < ApplicationController
13 13
 			return render 'new'
14 14
 		end
15 15
 
16
+		create_new_authentification()
16 17
 		flash.now[:notice] = I18n.t 'login.success'
17 18
 		render 'new'
18 19
 	end
... ...
@@ -5,6 +5,7 @@ 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"
... ...
@@ -1,5 +1,5 @@
1 1
 Xmpp::Application.routes.draw do
2
-	resources :sessions, only: [:new, :create, :destroy]
2
+	resources :sessions, only: [:create, :destroy]
3 3
 
4 4
   	root :to => 'sessions#new'
5 5