Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
veNJOB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thanh Hung Pham
veNJOB
Commits
7bc102de
Commit
7bc102de
authored
Jul 06, 2017
by
Thanh Hung Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate message
parent
b119f78f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
app/controllers/confirmations_controller.rb
+3
-1
app/controllers/registrations_controller.rb
+24
-0
app/models/user.rb
+3
-0
app/views/devise/confirmations/information.html.erb
+1
-1
config/locales/en.yml
+4
-1
No files found.
app/controllers/confirmations_controller.rb
View file @
7bc102de
class
ConfirmationsController
<
Devise
::
ConfirmationsController
def
update_confirm
@user
=
User
.
find
(
params
[
:user
][
:id
])
@user
=
User
.
find_by
(
params
[
:user
][
:id
])
@user
.
skip_password_validation
=
false
@user
.
skip_fullname_validation
=
false
if
@user
.
update_attributes
(
user_params
)
set_flash_message!
(
:notice
,
:confirmed
)
redirect_to
root_path
...
...
app/controllers/registrations_controller.rb
View file @
7bc102de
class
RegistrationsController
<
Devise
::
RegistrationsController
# POST /resource
def
create
build_resource
(
sign_up_params
)
resource
.
skip_password_validation
=
true
resource
.
skip_fullname_validation
=
true
resource
.
save
yield
resource
if
block_given?
if
resource
.
persisted?
if
resource
.
active_for_authentication?
set_flash_message!
:notice
,
:signed_up
sign_up
(
resource_name
,
resource
)
respond_with
resource
,
location:
after_sign_up_path_for
(
resource
)
else
set_flash_message!
:notice
,
:"signed_up_but_
#{
resource
.
inactive_message
}
"
expire_data_after_sign_in!
respond_with
resource
,
location:
after_inactive_sign_up_path_for
(
resource
)
end
else
clean_up_passwords
resource
set_minimum_password_length
respond_with
resource
end
end
protected
...
...
app/models/user.rb
View file @
7bc102de
class
User
<
ApplicationRecord
attr_accessor
:skip_password_validation
,
:skip_fullname_validation
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
...
...
@@ -6,4 +7,6 @@ class User < ApplicationRecord
:confirmable
,
:lockable
VALID_EMAIL_REGEX
=
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates
:email
,
length:
{
maximum:
255
},
format:
{
with:
VALID_EMAIL_REGEX
}
validates_presence_of
:fullname
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
validates_presence_of
:password
,
message:
"can't be empty"
,
unless: :skip_fullname_validation
end
app/views/devise/confirmations/information.html.erb
View file @
7bc102de
...
...
@@ -12,7 +12,7 @@
</div>
<div
class=
"form-group"
>
<%=
f
.
label
:fullname
%>
<%=
f
.
label
:fullname
,
'Full name'
%>
<%=
f
.
text_field
:fullname
,
autofocus:
true
,
class:
'form-control'
%>
</div>
...
...
config/locales/en.yml
View file @
7bc102de
...
...
@@ -30,4 +30,7 @@
# available at http://guides.rubyonrails.org/i18n.html.
en
:
hello
:
"
Hello
world"
activerecord
:
attributes
:
user
:
fullname
:
"
Full
Name"
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