Skip to content

Commit 98d57ba

Browse files
committed
添加devise的配置及相关文件。
1 parent 3631166 commit 98d57ba

29 files changed

Lines changed: 811 additions & 32 deletions

Gemfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ gem "omniauth-github"
127127
gem "devise"
128128
gem "devise-encryptable"
129129

130-
# 通知系统
131-
gem "notifications"
132-
gem "ruby-push-notifications"
133-
134130
# 拒绝低版本浏览器的访问,并给其返回一个让其升级的页面。
135131
# gem 'browser_warrior', '>= 0.8.0'
136132

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class ApplicationController < ActionController::Base
2+
protect_from_forgery prepend: true
23

34
end

app/controllers/users_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def edit
2424
# POST /users
2525
# POST /users.json
2626
def create
27-
binding.pry
2827
@user = User.new(user_params)
2928

3029
respond_to do |format|

app/models/user.rb

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22
#
33
# Table name: users
44
#
5-
# id :bigint not null, primary key
6-
# age(年龄) :string(255)
7-
# email(邮箱) :string(255)
8-
# name(用户名) :string(255)
9-
# password_digest(密码) :string(255)
10-
# sex(性别) :boolean
11-
# created_at :datetime not null
12-
# updated_at :datetime not null
5+
# id :bigint not null, primary key
6+
# age(年龄) :string(255)
7+
# email(邮箱) :string(255)
8+
# encrypted_password :string(255) default(""), not null
9+
# name(用户名) :string(255)
10+
# password_digest(密码) :string(255)
11+
# remember_created_at :datetime
12+
# reset_password_sent_at :datetime
13+
# reset_password_token :string(255)
14+
# sex(性别) :boolean
15+
# created_at :datetime not null
16+
# updated_at :datetime not null
17+
#
18+
# Indexes
19+
#
20+
# index_users_on_email (email) UNIQUE
21+
# index_users_on_reset_password_token (reset_password_token) UNIQUE
1322
#
1423

1524
class User < ApplicationRecord
@@ -26,4 +35,10 @@ class User < ApplicationRecord
2635
# user.password_digest # => "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4." 对password加密后的密码
2736
has_secure_password
2837

38+
# Include default devise modules. Others available are:
39+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
40+
devise :database_authenticatable, :registerable,
41+
:recoverable, :rememberable, :validatable
42+
43+
2944
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h2>Resend confirmation instructions</h2>
2+
3+
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4+
<%= render "devise/shared/error_messages", resource: resource %>
5+
6+
<div class="field">
7+
<%= f.label :email %><br />
8+
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
9+
</div>
10+
11+
<div class="actions">
12+
<%= f.submit "Resend confirmation instructions" %>
13+
</div>
14+
<% end %>
15+
16+
<%= render "devise/shared/links" %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>Welcome <%= @email %>!</p>
2+
3+
<p>You can confirm your account email through the link below:</p>
4+
5+
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Hello <%= @email %>!</p>
2+
3+
<% if @resource.try(:unconfirmed_email?) %>
4+
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
5+
<% else %>
6+
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
7+
<% end %>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>We're contacting you to notify you that your password has been changed.</p>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
4+
5+
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
6+
7+
<p>If you didn't request this, please ignore this email.</p>
8+
<p>Your password won't change until you access the link above and create a new one.</p>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Hello <%= @resource.email %>!</p>
2+
3+
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
4+
5+
<p>Click the link below to unlock your account:</p>
6+
7+
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>

0 commit comments

Comments
 (0)