-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(account invitations): rename account invitation to account share (…
…#42) * feat(account invitations): rename account invitation to account share * feat(account invitations): fixup! rename account invitation to account share * feat(account invitations): fixup! fixup! rename account invitation to account share --------- Co-authored-by: VladislavSokov <[email protected]>
- Loading branch information
1 parent
261d50f
commit 15c1beb
Showing
27 changed files
with
170 additions
and
157 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class AcceptAccountSharesController < ApplicationController | ||
def show | ||
return if user_signed_in? | ||
|
||
session[:after_sign_in_url] = request.fullpath | ||
|
||
shared_email = AccountShare.find_by!(token: ps.fetch(:token)).email | ||
user = User.find_by(email: shared_email) | ||
redirect_url = user ? new_user_session_url(email: shared_email) : new_user_registration_url(email: shared_email) | ||
|
||
redirect_to redirect_url | ||
end | ||
|
||
def update | ||
received_share.update!(accepted_at: Time.current) | ||
redirect_to account_path(received_share.account_id) | ||
end | ||
|
||
private | ||
|
||
helper_method memoize def received_share | ||
AccountShare.unaccepted.for(current_user).find_by!(token: ps.fetch(:token)) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountSharesController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def index; end | ||
|
||
def new; end | ||
|
||
def create | ||
personal_account_share = AccountShare.create!(user_id: current_user.id, | ||
account_id: account.id, | ||
token: SecureRandom.urlsafe_base64(32), | ||
**account_share_params) | ||
AccountShareMailer.account_share(personal_account_share).deliver | ||
redirect_to account_shares_path account | ||
end | ||
|
||
def destroy | ||
personal_account_share = AccountShare.find(ps.fetch(:id)) | ||
personal_account_share.destroy | ||
respond_to do |format| | ||
format.html { redirect_to account_shares_url, notice: 'Account share was successfully destroyed.' } | ||
end | ||
end | ||
|
||
private | ||
|
||
def account_share_params | ||
params.require(:account_share).permit(:name, :email) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class AccountShareMailer < ApplicationMailer | ||
def account_share(account_share) | ||
@account_share = account_share | ||
|
||
mail to: account_share.email, subject: 'Share to manage an account!' | ||
end | ||
end |
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
6 changes: 3 additions & 3 deletions
6
...accept_account_invitations/show.html.slim → ...iews/accept_account_shares/show.html.slim
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,13 +1,13 @@ | ||
div.columns.is-centered.is-vcentered | ||
div.column.is-two-third | ||
h4.subtitle.has-text-centered | ||
| Dear #{received_invitation.name} | ||
| Dear #{received_share.name} | ||
h6.subtitle.has-text-centered | ||
| I am delighted to invite you to manage the account | ||
| You've been shared access to manage the account | ||
br | ||
br | ||
div.buttons.is-centered | ||
= link_to 'Accept', accept_account_invitation_path, method: :patch, class: 'button is-success is-medium' | ||
= link_to 'Accept', accept_account_share_path, method: :patch, class: 'button is-success is-medium' | ||
span.has-text-grey-light | ||
|
||
= link_to 'Cancel', root_path, class: 'button is-light is-medium' |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h2>Dear <%= @account_share.name%>, welcome to managing my account!</h2> | ||
<br> | ||
<p>Click the link to approve the share</p> | ||
<%= link_to 'Go and approve the share', accept_account_share_url(token: @account_share.token) %> | ||
<br> | ||
<!-- TODO: add curent user name --> | ||
<p>Sincerely, </p> |
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,7 @@ | ||
tr | ||
td= account_share.name | ||
td= account_share.email | ||
td= account_share.created_at.to_formatted_s(:short) | ||
td= account_share.accepted_at&.to_formatted_s(:short) | ||
td= link_to 'link', accept_account_share_url(token: account_share.token) | ||
td= link_to :delete, account_share_path(account, account_share), method: :delete, data: {confirm: 'Delete this share?'} |
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,16 @@ | ||
<div class="columns"> | ||
<div class="column is-three-quarters"> | ||
<%= link_to 'Back', account_shares_path, class: 'button is-light' %> | ||
</div> | ||
<div class="column is-flex is-justify-content-flex-end"> | ||
</div> | ||
</div> | ||
<%= form_with url: account_shares_path, method: :post do |form| %> | ||
<div class="column is-one-third"> | ||
<%= form.label :name %> | ||
<%= form.text_field :name, name: 'account_share[name]', type:"text", class: 'input'%> | ||
<%= form.label :email %> | ||
<%= form.email_field :email, name: 'account_share[email]', type: "email"%> | ||
</div> | ||
<%= form.submit :Create, class: 'button is-light' %> | ||
<% 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 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
7 changes: 7 additions & 0 deletions
7
db/migrate/20230830131000_rename_account_invitations_table.rb
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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class RenameAccountInvitationsTable < ActiveRecord::Migration[6.1] | ||
def change | ||
rename_table :account_invitations, :account_shares | ||
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
Oops, something went wrong.