-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
157 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProfilesController < ApplicationController | ||
include EventRouting | ||
|
||
def show; 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,13 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
class SessionsController < ApplicationController | ||
skip_before_action :set_user | ||
skip_before_action :set_plan | ||
skip_before_action :set_locale | ||
skip_before_action :set_last_path | ||
|
||
def create | ||
user_info = request.env['omniauth.auth'] | ||
redirect_to session[:last_path] | ||
profile = Profile.find_by(uid: user_info['uid']) | ||
|
||
if profile | ||
session[:user_id] = profile.user.id | ||
else | ||
create_and_set_user unless @user | ||
@user.create_profile( | ||
provider: user_info['provider'], | ||
uid: user_info['uid'], | ||
name: user_info['info']['name'], | ||
email: user_info['info']['email'], | ||
avatar_url: user_info['info']['image'] | ||
) | ||
end | ||
|
||
redirect_to session[:last_path] || root_path | ||
end | ||
|
||
def delete | ||
session[:user_id] = nil | ||
|
||
redirect_to root_path | ||
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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
module ProfilesHelper | ||
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,30 @@ | ||
<% if @user && @user.profile %> | ||
<div class="flex justify-center"> | ||
<div class="w-1/2"> | ||
<div class="w-full min-w-[400px] h-fit p-4 shadow-[0_1px_2px_0_rgba(3,3,2,0.3)] rounded-md bg-white"> | ||
<div class="flex gap-4"> | ||
<img class="w-36 h-36 rounded-full" src="<%= @user.profile.avatar_url %>"> | ||
<div class="flex flex-col gap-2"> | ||
<h1 class="text-4xl"><%= @user.profile.name %></h1> | ||
<h2><%= @user.profile.email %></h2> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% else %> | ||
<div class="flex items-center justify-center h-96"> | ||
<div class="h-auto"> | ||
<%= form_tag('/auth/github', method: 'post' , data: {turbo: false}) do %> | ||
<button type='submit' class="p-2 border border-black border-solid rounded-md"> | ||
<div class="flex items-center gap-2"> | ||
<img src="/icons/github-mark.svg" class="w-6 h-6"> | ||
<span class="font-bold"> | ||
Sign up with GitHub | ||
</span> | ||
</div> | ||
</button> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | ||
|
||
require 'test_helper' | ||
|
||
class ProfilesControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# 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