Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
blog_devise
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mis-21-2018-intersession
rails
blog_devise
Commits
cab3fb7e
Commit
cab3fb7e
authored
Jul 11, 2018
by
John Noel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished initial Devise User setup
parent
bba52e26
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
251 additions
and
0 deletions
+251
-0
user.rb
app/models/user.rb
+6
-0
new.html.erb
app/views/users/confirmations/new.html.erb
+16
-0
confirmation_instructions.html.erb
app/views/users/mailer/confirmation_instructions.html.erb
+5
-0
email_changed.html.erb
app/views/users/mailer/email_changed.html.erb
+7
-0
password_change.html.erb
app/views/users/mailer/password_change.html.erb
+3
-0
reset_password_instructions.html.erb
app/views/users/mailer/reset_password_instructions.html.erb
+8
-0
unlock_instructions.html.erb
app/views/users/mailer/unlock_instructions.html.erb
+7
-0
edit.html.erb
app/views/users/passwords/edit.html.erb
+19
-0
new.html.erb
app/views/users/passwords/new.html.erb
+15
-0
edit.html.erb
app/views/users/registrations/edit.html.erb
+27
-0
new.html.erb
app/views/users/registrations/new.html.erb
+17
-0
new.html.erb
app/views/users/sessions/new.html.erb
+15
-0
_links.html.erb
app/views/users/shared/_links.html.erb
+25
-0
new.html.erb
app/views/users/unlocks/new.html.erb
+16
-0
routes.rb
config/routes.rb
+1
-0
20180711105122_devise_create_users.rb
db/migrate/20180711105122_devise_create_users.rb
+46
-0
users.yml
test/fixtures/users.yml
+11
-0
user_test.rb
test/models/user_test.rb
+7
-0
No files found.
app/models/user.rb
0 → 100644
View file @
cab3fb7e
class
User
<
ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
end
app/views/users/confirmations/new.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Resend confirmation instructions
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
confirmation_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
<%=
f
.
error_notification
%>
<%=
f
.
full_error
:confirmation_token
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Resend confirmation instructions"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
app/views/users/mailer/confirmation_instructions.html.erb
0 → 100644
View file @
cab3fb7e
<p>
Welcome
<%=
@email
%>
!
</p>
<p>
You can confirm your account email through the link below:
</p>
<p>
<%=
link_to
'Confirm my account'
,
confirmation_url
(
@resource
,
confirmation_token:
@token
)
%>
</p>
app/views/users/mailer/email_changed.html.erb
0 → 100644
View file @
cab3fb7e
<p>
Hello
<%=
@email
%>
!
</p>
<%
if
@resource
.
try
(
:unconfirmed_email?
)
%>
<p>
We're contacting you to notify you that your email is being changed to
<%=
@resource
.
unconfirmed_email
%>
.
</p>
<%
else
%>
<p>
We're contacting you to notify you that your email has been changed to
<%=
@resource
.
email
%>
.
</p>
<%
end
%>
app/views/users/mailer/password_change.html.erb
0 → 100644
View file @
cab3fb7e
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
We're contacting you to notify you that your password has been changed.
</p>
app/views/users/mailer/reset_password_instructions.html.erb
0 → 100644
View file @
cab3fb7e
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
Someone has requested a link to change your password. You can do this through the link below.
</p>
<p>
<%=
link_to
'Change my password'
,
edit_password_url
(
@resource
,
reset_password_token:
@token
)
%>
</p>
<p>
If you didn't request this, please ignore this email.
</p>
<p>
Your password won't change until you access the link above and create a new one.
</p>
app/views/users/mailer/unlock_instructions.html.erb
0 → 100644
View file @
cab3fb7e
<p>
Hello
<%=
@resource
.
email
%>
!
</p>
<p>
Your account has been locked due to an excessive number of unsuccessful sign in attempts.
</p>
<p>
Click the link below to unlock your account:
</p>
<p>
<%=
link_to
'Unlock my account'
,
unlock_url
(
@resource
,
unlock_token:
@token
)
%>
</p>
app/views/users/passwords/edit.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Change your password
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
password_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
<%=
f
.
error_notification
%>
<%=
f
.
input
:reset_password_token
,
as: :hidden
%>
<%=
f
.
full_error
:reset_password_token
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:password
,
label:
"New password"
,
required:
true
,
autofocus:
true
,
hint:
(
"
#{
@minimum_password_length
}
characters minimum"
if
@minimum_password_length
)
%>
<%=
f
.
input
:password_confirmation
,
label:
"Confirm your new password"
,
required:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Change my password"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
app/views/users/passwords/new.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Forgot your password?
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
password_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
<%=
f
.
error_notification
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Send me reset password instructions"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
app/views/users/registrations/edit.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Edit
<%=
resource_name
.
to_s
.
humanize
%>
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
),
html:
{
method: :put
})
do
|
f
|
%>
<%=
f
.
error_notification
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
<%
if
devise_mapping
.
confirmable?
&&
resource
.
pending_reconfirmation?
%>
<p>
Currently waiting confirmation for:
<%=
resource
.
unconfirmed_email
%>
</p>
<%
end
%>
<%=
f
.
input
:password
,
autocomplete:
"off"
,
hint:
"leave it blank if you don't want to change it"
,
required:
false
%>
<%=
f
.
input
:password_confirmation
,
required:
false
%>
<%=
f
.
input
:current_password
,
hint:
"we need your current password to confirm your changes"
,
required:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Update"
%>
</div>
<%
end
%>
<h3>
Cancel my account
</h3>
<p>
Unhappy?
<%=
link_to
"Cancel my account"
,
registration_path
(
resource_name
),
data:
{
confirm:
"Are you sure?"
},
method: :delete
%>
</p>
<%=
link_to
"Back"
,
:back
%>
app/views/users/registrations/new.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Sign up
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
registration_path
(
resource_name
))
do
|
f
|
%>
<%=
f
.
error_notification
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
<%=
f
.
input
:password
,
required:
true
,
hint:
(
"
#{
@minimum_password_length
}
characters minimum"
if
@minimum_password_length
)
%>
<%=
f
.
input
:password_confirmation
,
required:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Sign up"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
app/views/users/sessions/new.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Log in
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
session_path
(
resource_name
))
do
|
f
|
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
false
,
autofocus:
true
%>
<%=
f
.
input
:password
,
required:
false
%>
<%=
f
.
input
:remember_me
,
as: :boolean
if
devise_mapping
.
rememberable?
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Log in"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
app/views/users/shared/_links.html.erb
0 → 100644
View file @
cab3fb7e
<%-
if
controller_name
!=
'sessions'
%>
<%=
link_to
"Log in"
,
new_session_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
<%-
if
devise_mapping
.
registerable?
&&
controller_name
!=
'registrations'
%>
<%=
link_to
"Sign up"
,
new_registration_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
<%-
if
devise_mapping
.
recoverable?
&&
controller_name
!=
'passwords'
&&
controller_name
!=
'registrations'
%>
<%=
link_to
"Forgot your password?"
,
new_password_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
<%-
if
devise_mapping
.
confirmable?
&&
controller_name
!=
'confirmations'
%>
<%=
link_to
"Didn't receive confirmation instructions?"
,
new_confirmation_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
<%-
if
devise_mapping
.
lockable?
&&
resource_class
.
unlock_strategy_enabled?
(
:email
)
&&
controller_name
!=
'unlocks'
%>
<%=
link_to
"Didn't receive unlock instructions?"
,
new_unlock_path
(
resource_name
)
%>
<br
/>
<%
end
-%>
<%-
if
devise_mapping
.
omniauthable?
%>
<%-
resource_class
.
omniauth_providers
.
each
do
|
provider
|
%>
<%=
link_to
"Sign in with
#{
OmniAuth
::
Utils
.
camelize
(
provider
)
}
"
,
omniauth_authorize_path
(
resource_name
,
provider
)
%>
<br
/>
<%
end
-%>
<%
end
-%>
app/views/users/unlocks/new.html.erb
0 → 100644
View file @
cab3fb7e
<h2>
Resend unlock instructions
</h2>
<%=
simple_form_for
(
resource
,
as:
resource_name
,
url:
unlock_path
(
resource_name
),
html:
{
method: :post
})
do
|
f
|
%>
<%=
f
.
error_notification
%>
<%=
f
.
full_error
:unlock_token
%>
<div
class=
"form-inputs"
>
<%=
f
.
input
:email
,
required:
true
,
autofocus:
true
%>
</div>
<div
class=
"form-actions"
>
<%=
f
.
button
:submit
,
"Resend unlock instructions"
%>
</div>
<%
end
%>
<%=
render
"users/shared/links"
%>
config/routes.rb
View file @
cab3fb7e
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
devise_for
:users
resources
:posts
resources
:posts
root
to:
'posts#index'
root
to:
'posts#index'
end
end
\ No newline at end of file
db/migrate/20180711105122_devise_create_users.rb
0 → 100644
View file @
cab3fb7e
# frozen_string_literal: true
class
DeviseCreateUsers
<
ActiveRecord
::
Migration
[
5.2
]
def
change
create_table
:users
do
|
t
|
## Database authenticatable
t
.
string
:email
,
null:
false
,
default:
""
t
.
string
:encrypted_password
,
null:
false
,
default:
""
## Recoverable
t
.
string
:reset_password_token
t
.
datetime
:reset_password_sent_at
## Rememberable
t
.
datetime
:remember_created_at
## Trackable
t
.
integer
:sign_in_count
,
default:
0
,
null:
false
t
.
datetime
:current_sign_in_at
t
.
datetime
:last_sign_in_at
t
.
string
:current_sign_in_ip
t
.
string
:last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t
.
string
:first_name
t
.
string
:last_name
t
.
timestamps
null:
false
end
add_index
:users
,
:email
,
unique:
true
add_index
:users
,
:reset_password_token
,
unique:
true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end
end
test/fixtures/users.yml
0 → 100644
View file @
cab3fb7e
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one
:
{}
# column: value
#
two
:
{}
# column: value
test/models/user_test.rb
0 → 100644
View file @
cab3fb7e
require
'test_helper'
class
UserTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
end
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