Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Agendador
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Agendador
Agendador
Commits
e9624af0
Commit
e9624af0
authored
Nov 22, 2016
by
Pedro Henrique
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blocks citizen when trying to login in an inactive city
Signed-off-by:
Pedro Henrique!
<
pha14@inf.ufpr.br
>
parent
98847996
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+8
-6
No files found.
app/controllers/sessions_controller.rb
View file @
e9624af0
...
@@ -21,10 +21,13 @@ class SessionsController < Devise::SessionsController
...
@@ -21,10 +21,13 @@ class SessionsController < Devise::SessionsController
# yield resource if block_given?
# yield resource if block_given?
# respond_with resource, location: after_sign_in_path_for(resource)
# respond_with resource, location: after_sign_in_path_for(resource)
# Get status of current city
current_city
=
CityHall
.
find_by
(
city_id:
current_citizen
.
city_id
)
# Get resource
# Get resource
self
.
resource
=
warden
.
authenticate!
(
auth_options
)
self
.
resource
=
warden
.
authenticate!
(
auth_options
)
# Check if resource is not null and if a citizen has been signed_in
# Check if resource is not null and if a citizen has been signed_in
if
!
resource
.
nil?
&&
citizen_signed_in?
if
!
resource
.
nil?
&&
citizen_signed_in?
&&
current_city
.
active
# if !resource.active
# if !resource.active
# sign_out(resource)
# sign_out(resource)
...
@@ -32,7 +35,7 @@ class SessionsController < Devise::SessionsController
...
@@ -32,7 +35,7 @@ class SessionsController < Devise::SessionsController
# return redirect_to root_path
# return redirect_to root_path
# end
# end
# Set expire
s time to send message when expiring
# Set expire
tion time to send message when expiring session
session
[
:expires_at
]
=
Time
.
current
+
30
.
minutes
session
[
:expires_at
]
=
Time
.
current
+
30
.
minutes
# Set variable to show loading bar
# Set variable to show loading bar
session
[
:carrega_pagina
]
=
true
session
[
:carrega_pagina
]
=
true
...
@@ -56,11 +59,10 @@ class SessionsController < Devise::SessionsController
...
@@ -56,11 +59,10 @@ class SessionsController < Devise::SessionsController
redirect_to
root_path
redirect_to
root_path
end
end
else
else
if
(
!
@current_city_hall
.
citizen_access
)
if
!
current_city
.
active
||
(
!
@current_city_hall
.
citizen_access
)
sign_out
(
resource
)
sign_out
(
resource
)
mensagem
=
"A utilização do agendador pela internet está
mensagem
=
"A utilização do agendador nesta cidade está desativado"
desatibilitada nesta cidade. "
if
@city_hall
&&
@city_hall
.
textoBloqueio
if
@city_hall
.
textoBloqueio
mensagem
+=
@city_hall
.
textoBloqueio
mensagem
+=
@city_hall
.
textoBloqueio
end
end
return
redirect_to
root_path
,
alert:
mensagem
.
html_safe
return
redirect_to
root_path
,
alert:
mensagem
.
html_safe
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment