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
annotate routes
  • Loading branch information
yshmarov committed Nov 9, 2022
commit 5e62487d32878d27a4199985d19b0a2a6a2728e5
8 changes: 4 additions & 4 deletions app/controllers/insta_posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class InstaPostsController < ApplicationController
before_action :set_user

# all posts
# GET /u/:id/p
def index
cookies[:view] = params[:view] if params[:view].present? && %w[grid list].include?(params[:view])

Expand All @@ -13,16 +13,16 @@ def index
end
end

# single post
# GET /u/:id/p/:post_id
def show
@post = @insta_user.insta_posts.find(params[:post_id])
@post = @insta_user.insta_posts.find(params[:id])
@posts = @insta_user.insta_posts.without(@post).order('RANDOM()').limit(6)
end

private

def set_user
@insta_user = InstaUser.find(params[:id])
@insta_user = InstaUser.find(params[:user_id])
seo_tags
end

Expand Down
5 changes: 3 additions & 2 deletions app/controllers/insta_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ class InstaUsersController < ApplicationController
before_action :set_user, only: %i[show import]
before_action :require_user!, only: :import

# discovery feature
# GET /u
def index
@insta_users = InstaUser.where.not(insta_posts_count: 0).order(insta_posts_count: :desc)
set_meta_tags title: 'Blogs',
description: 'all instagram pages converted into blogs'
end

# TODO: use this instead of insta_posts#index?
# GET /u/:id
def show
redirect_to insta_user_posts_path(@insta_user)
end

# POST /u/:id/import
def import
return unless @insta_user.user == current_user

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/instagram_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ def callback
redirect_to user_path
end

# TODO: move to other controller?
# GET /instagram/delete
def delete
render plain: 'Please contact [email protected] to delete your data'
end

# GET /instagram/deauthorize
def deauthorize
render plain: 'Please contact [email protected] to deauthorize the app'
end
Expand All @@ -38,10 +39,8 @@ def deauthorize

def redirect_uri
if Rails.env.production?
# Rails.application.routes.url_helpers.instagram_callback_url
instagram_callback_url
else
# staging
# 'localhost:3000/instagram/callback/'
# 'https://insta2blog.com/instagram/callback'
'https://insta2site.herokuapp.com/'
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
class StaticPagesController < ApplicationController
before_action :seo_tags, only: %i[terms privacy pricing]

# GET /
def landing_page
count = InstaUser.count
random_offset = rand(count)
@random_user = InstaUser.offset(random_offset).first
end

# GET /terms
def terms; end

# GET /privacy
def privacy; end

# GET /pricing
def pricing; end

private
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class UsersController < ApplicationController
before_action :require_user!

# GET /me
def show
@user = current_user
@insta_users = @user.insta_users.order(created_at: :desc)
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
get 'u/:id', to: 'insta_users#show', as: :insta_user
post 'u/:id/import', to: 'insta_users#import', as: :import_insta_user

get 'u/:id/p', to: 'insta_posts#index', as: :insta_user_posts
get 'u/:id/p/:post_id', to: 'insta_posts#show', as: :insta_user_post
get 'u/:user_id/p', to: 'insta_posts#index', as: :insta_user_posts
get 'u/:user_id/p/:id', to: 'insta_posts#show', as: :insta_user_post
end