Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
5b407802
Commit
5b407802
authored
Jun 13, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Password expire: implement password resource inside profile. add before_fiter check
parent
81a9e81f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+7
-0
app/controllers/passwords_controller.rb
app/controllers/passwords_controller.rb
+35
-0
app/views/passwords/new.html.haml
app/views/passwords/new.html.haml
+23
-0
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/controllers/application_controller.rb
View file @
5b407802
class
ApplicationController
<
ActionController
::
Base
before_filter
:authenticate_user!
before_filter
:reject_blocked!
before_filter
:check_password_expiration!
before_filter
:set_current_user_for_thread
before_filter
:add_abilities
before_filter
:dev_tools
if
Rails
.
env
==
'development'
...
...
@@ -156,4 +157,10 @@ class ApplicationController < ActionController::Base
gon
.
gravatar_url
=
request
.
ssl?
||
Gitlab
.
config
.
gitlab
.
https
?
Gitlab
.
config
.
gravatar
.
ssl_url
:
Gitlab
.
config
.
gravatar
.
plain_url
gon
.
relative_url_root
=
Gitlab
.
config
.
gitlab
.
relative_url_root
end
def
check_password_expiration
if
current_user
.
password_expires_at
<
Time
.
now
redirect_to
new_profile_password_path
and
return
end
end
end
app/controllers/passwords_controller.rb
0 → 100644
View file @
5b407802
class
PasswordsController
<
ApplicationController
layout
'navless'
before_filter
:set_user
before_filter
:set_title
def
new
end
def
create
new_password
=
params
[
:user
][
:password
]
new_password_confirmation
=
params
[
:user
][
:password_confirmation
]
result
=
@user
.
update_attributes
(
password:
new_password
,
password_confirmation:
new_password_confirmation
)
if
result
redirect_to
root_path
(
notice:
'Password successfully changed'
)
else
render
:new
end
end
private
def
set_user
@user
=
current_user
end
def
set_title
@title
=
"New password"
end
end
app/views/passwords/new.html.haml
0 → 100644
View file @
5b407802
%h3
.page_title
Setup your new password
%br
=
form_for
@user
,
url:
profile_password_path
,
method: :put
do
|
f
|
.padded
%p
.slead
After successful password update you will be redirected to dashboard
-
if
@user
.
errors
.
any?
.alert.alert-error
%ul
-
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.clearfix
=
f
.
label
:password
.input
=
f
.
password_field
:password
,
required:
true
.clearfix
=
f
.
label
:password_confirmation
.input
=
f
.
password_field
:password_confirmation
,
required:
true
.clearfix
.input
=
f
.
submit
'Save password'
,
class:
"btn btn-save"
config/routes.rb
View file @
5b407802
...
...
@@ -123,6 +123,7 @@ Gitlab::Application.routes.draw do
end
resource
:notifications
resource
:password
end
resources
:keys
...
...
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