Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

74 auth via email link gem passwordless #75

Merged
merged 28 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bc15fcc
add passwordless
yshmarov Nov 8, 2022
d2e34ba
add gem letter-opener
yshmarov Nov 8, 2022
973942c
add passwordless views
yshmarov Nov 8, 2022
333b627
make sign in work
yshmarov Nov 8, 2022
0775293
users#show, basic views work
yshmarov Nov 8, 2022
bb9897a
Update new.html.erb
yshmarov Nov 8, 2022
6830e43
no more need to load insta user in session
yshmarov Nov 8, 2022
c9c0bac
insta user belongs to user
yshmarov Nov 8, 2022
a56e780
add passwordless initializer
yshmarov Nov 8, 2022
babb292
prepare for sending emails in production
yshmarov Nov 8, 2022
2ea5c44
require user for users controller, i18n
yshmarov Nov 8, 2022
37d2719
Update new.html.erb
yshmarov Nov 8, 2022
fcc20b6
associate insta user with user
yshmarov Nov 8, 2022
a6e15ff
display insta users of a user
yshmarov Nov 8, 2022
a88413a
no need for user partial in insta users index
yshmarov Nov 8, 2022
479b9d7
validation for import action
yshmarov Nov 8, 2022
074b6c0
move import action from ig_posts to ig_user
yshmarov Nov 8, 2022
0b4bcbb
Update show.html.erb
yshmarov Nov 8, 2022
edb31c7
Update show.html.erb
yshmarov Nov 8, 2022
0e9acd5
fix import
yshmarov Nov 9, 2022
52e1237
depreciate insta_user#show in favour of insta posts#index
yshmarov Nov 9, 2022
e9f56ef
Update new.html.erb
yshmarov Nov 9, 2022
3dafeba
after connect insta account redirect to user path
yshmarov Nov 9, 2022
32e2b91
Update users_controller.rb
yshmarov Nov 9, 2022
5e62487
annotate routes
yshmarov Nov 9, 2022
02573bb
update tests
yshmarov Nov 9, 2022
18c48da
update AWS SES creds for prod
yshmarov Nov 9, 2022
2fec4b0
Update user.rb
yshmarov Nov 9, 2022
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
Prev Previous commit
Next Next commit
users#show, basic views work
  • Loading branch information
yshmarov committed Nov 8, 2022
commit 0775293e743eb5e56d8695cbc61e280dc07cad66
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ group :development do

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
gem "letter_opener"
gem 'letter_opener'
end

group :test do
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class UsersController < ApplicationController
def show
end
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class User < ApplicationRecord
def self.fetch_resource_for_passwordless(email)
find_or_create_by(email:)
end

def username
email.split('@').first
end
end
2 changes: 1 addition & 1 deletion app/views/insta_users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2>
🦄
<%= pluralize(@insta_users.length, 'person') %>
successfully converted their instas' to blogs:
successfully converted their instas' to blogs
</h2>

<% @insta_users.each do |insta_user| %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/shared/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<span class='hidden lg:block'>Explore</span>
<% end %>
<% if current_user %>
<%= link_to insta_user_path(current_user), class: 'flex items-center space-x-2 p-2 rounded-md hover:bg-slate-100' do %>
<%= link_to user_path, class: 'flex items-center space-x-2 p-2 rounded-md hover:bg-slate-100' do %>
<i class="fa-solid fa-house text-slate-700"></i>
<span class='hidden lg:block'><%= current_user.at_username %></span>
<span class='hidden lg:block'><%= current_user.username %></span>
<% end %>
<%= button_to logout_path, method: :delete, class: 'flex items-center space-x-2 p-2 rounded-md hover:bg-slate-100', form: { data: { turbo_confirm: 'Log out?' } } do %>
<%= button_to auth.sign_out_path, method: :delete, class: 'flex items-center space-x-2 p-2 rounded-md hover:bg-slate-100', form: { data: { turbo_confirm: 'Log out?' } } do %>
<i class="fa-solid fa-arrow-right-from-bracket text-slate-700"></i>
<span class='hidden lg:block'>Logout</span>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/static_pages/landing_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<div>
<% if current_user %>
<%= render partial: 'insta_users/insta_user', locals: { insta_user: current_user } %>
<%= link_to 'Open app', user_path, class: 'bg-violet-700 hover:bg-violet-900 text-fuchsia-50 p-4 rounded-md font-bold' %>
<% else %>
<%= link_to '🎯 Connect your Instagram', instagram_authorize_path, class: 'bg-violet-700 hover:bg-violet-900 text-fuchsia-50 p-4 rounded-md font-bold' %>
<%= link_to '🎯 Connect your Instagram', auth.sign_in_path, class: 'bg-violet-700 hover:bg-violet-900 text-fuchsia-50 p-4 rounded-md font-bold' %>
<% end %>
</div>
</section>
Expand Down
4 changes: 4 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= link_to instagram_authorize_path, class: 'flex items-center space-x-2 font-bold bg-violet-700 hover:bg-violet-900 text-fuchsia-50 p-2 rounded-md' do %>
<i class="fa-brands fa-instagram"></i>
<span>Connect an Instagram account</span>
<% end %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# passwordless_for :users
passwordless_for :users, at: '/', as: :auth

get 'me', to: 'users#show', as: :user

get 'instagram/authorize', to: "instagram#authorize"
get 'instagram/callback', to: "instagram#callback"
get 'instagram/deauthorize', to: "instagram#deauthorize"
Expand Down
2 changes: 1 addition & 1 deletion test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "test_helper"
require 'test_helper'

class UserTest < ActiveSupport::TestCase
# test "the truth" do
Expand Down