Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions app/controllers/recovery_tokens_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class RecoveryTokensController < ApplicationController
# /recovery_tokens
def new
@is_login_page = true
@does_not_have_sidebar = true
end

def create
@is_login_page = true
@does_not_have_sidebar = true
@api_body = { email: params[:email] }
@api_path = '/recovery_tokens'
api_call
rescue => e
@is_login_page = true
@does_not_have_sidebar = true
@invalid_email = true
render :new
end

# /reset_password
def edit
redirect_to :dashboard if params[:token].nil?
@is_login_page = true
@does_not_have_sidebar = true
end

def reset
@is_login_page = true
@does_not_have_sidebar = true
@api_body = {
password: params[:password],
password_confirmation: params[:password_confirmation],
token: params[:token]
}
@api_path = "/recovery_tokens/#{params[:token]}"
api_call
rescue ApiClient::Unauthorized
@is_login_page = true
@does_not_have_sidebar = true
@invalid_password = true
render :edit
rescue # ApiClient::NotFound
@is_login_page = true
@does_not_have_sidebar = true
@invalid_token = true
render :edit
end
end
9 changes: 9 additions & 0 deletions app/views/recovery_tokens/create.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- set_title "パスワードリセット"

#login.container
h2 パスワードのリセット方法を記載したメールを送信しました
p メールが届くまでお待ちください。メールが届かない場合は、以下の注意点をご確認ください:
ul
li 迷惑メールボックスに入っていないか
li システムのメールを受信拒否していないか
p もし何度か試してもメールが届かない場合は、学園祭実行委員会室までお越しいただき、その旨をお伝え下さい。
22 changes: 22 additions & 0 deletions app/views/recovery_tokens/edit.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- set_title "パスワードリセット"

#login.container
h1 パスワードリセット

p 新しいパスワードを入力してください
.row
.col-sm-6
form method="POST"
- if @invalid_password
.alert.alert-danger
| パスワードが不正です
- if @invalid_token
.alert.alert-danger
| トークンが不正です。パスワードをリセットしたい場合は、もう一度メールを#{link_to 'こちら', path_to(:recovery_tokens)}から送信してください
input type="hidden" name="authenticity_token" value="#{form_authenticity_token}"
.form-group
input#email-address.form-control type="password" name="password" placeholder="新しいパスワード"
.form-group
input#email-address.form-control type="password" name="password_confirmation" placeholder="新しいパスワードの確認"
.form-group
button.btn.btn-primary type='submit' 送信
18 changes: 18 additions & 0 deletions app/views/recovery_tokens/new.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- set_title "ログインできないとき"

#login.container
h1 ログインできないとき

h3 パスワードがわからない
p 以下のフォームから登録に使用したメールアドレスを送信してください。
.row
.col-sm-6
form.form-inline method="POST"
input type="hidden" name="authenticity_token" value="#{form_authenticity_token}"
.form-group
input#email-address.form-control type="email" name="email" placeholder="メールアドレス"
.form-group
button.btn.btn-primary type='submit' 送信

h3 アカウント名、またはアカウント名とパスワードの両方がわからない
p 学園祭実行委員会室までお越しいただき、その旨をお伝え下さい。
8 changes: 8 additions & 0 deletions app/views/recovery_tokens/reset.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- set_title "パスワードリセットが完了しました"

#login.container
h1 パスワードリセットが完了しました
.form-group
= link_to path_to(:dashboard), class: "btn btn-default"
span.glyphicon.glyphicon-dashboard
| ダッシュボードへ
11 changes: 8 additions & 3 deletions app/views/sessions/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
.col-sm-8.col-sm-offset-2
hr
.text-center
= link_to path_to(:register), class: "btn btn-lg btn-success" do
span.glyphicon.glyphicon-plus-sign aria-hidden='true'
| アカウントを作成
p
= link_to path_to(:register), class: "btn btn-lg btn-success" do
span.glyphicon.glyphicon-plus-sign aria-hidden='true'
| アカウントを作成
p
= link_to path_to(:recovery_tokens), class: "btn btn-default" do
span.glyphicon.glyphicon-question-sign
| ログインできないとき
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
get :logout, controller: 'sessions', action: :edit
post :logout, controller: 'sessions', action: :destroy

# reset password
get :recovery_tokens, controller: 'recovery_tokens', action: :new
post :recovery_tokens, controller: 'recovery_tokens', action: :create
get :reset_password, controller: 'recovery_tokens', action: :edit
post :reset_password, controller: 'recovery_tokens', action: :reset

get :register, controller: 'accounts', action: :new
post :register, controller: 'accounts', action: :create

get 'register/confirm', controller: 'accounts', action: :confirm

resources :projects,
only: [:show, :edit, :new, :create] do

Expand Down