forked from openware/barong
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all logic from profile show to accounts show (close openware#449)
- Loading branch information
1 parent
3e66f25
commit c945a06
Showing
15 changed files
with
179 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountMailer < Devise::Mailer | ||
include SkipEmails | ||
|
||
def confirmation_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def reset_password_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def unlock_instructions(record, token, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def email_changed(record, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
|
||
def password_change(record, opts = {}) | ||
send_email_if_enabled { super } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationMailer < ActionMailer::Base | ||
default from: 'from@example.com' | ||
include SkipEmails | ||
|
||
default from: ENV.fetch('SENDER_EMAIL', 'noreply@barong.io') | ||
layout 'mailer' | ||
|
||
def mail(options) | ||
send_email_if_enabled { super } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module SkipEmails | ||
extend ActiveSupport::Concern | ||
|
||
def send_email_if_enabled | ||
raise 'Block is required' unless block_given? | ||
|
||
if ENV['SKIP_EMAILS'] | ||
return Rails.logger.info 'Emails are skip. You need to use Event API to handle emails manually' | ||
end | ||
|
||
yield | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<%= form_with(model: [:admin, @profile], local: false) do |form| %> | ||
<% if profile.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(profile.errors.count, "error") %> prohibited this website from being saved:</h2> | ||
|
||
<ul> | ||
<% profile.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
<%= form.label :first_name, class: 'control-label'%> | ||
<%= form.text_field :first_name, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :last_name, class: 'control-label'%> | ||
<%= form.text_field :last_name, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :dob, class: 'control-label'%> | ||
<%= form.text_field :dob, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :address, class: 'control-label'%> | ||
<%= form.text_field :address, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :postcode, class: 'control-label'%> | ||
<%= form.text_field :postcode, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :city, class: 'control-label'%> | ||
<%= form.text_field :city, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.label :country, class: 'control-label'%> | ||
<%= form.text_field :country, class: 'form-control col-sm-10'%> | ||
<br> | ||
|
||
<%= form.submit 'Submit', class: 'btn btn-primary' %> | ||
|
||
<br> | ||
<br> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="container"> | ||
<h1>Editing profile</h1> | ||
<%= render 'form', profile: @profile %> | ||
<br> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters