mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 22:15:14 +00:00
Add github unlink + relink options
This commit is contained in:
parent
883acfde52
commit
fa00180e86
3 changed files with 23 additions and 0 deletions
|
|
@ -82,6 +82,17 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def github_unlink
|
||||
unless current_user
|
||||
redirect_to root_path, alert: "Please sign in first"
|
||||
return
|
||||
end
|
||||
|
||||
current_user.update!(github_access_token: nil)
|
||||
Rails.logger.info "GitHub account unlinked for User ##{current_user.id}"
|
||||
redirect_to my_settings_path, notice: "GitHub account unlinked successfully"
|
||||
end
|
||||
|
||||
def email
|
||||
email = params[:email].downcase
|
||||
continue_param = params[:continue]
|
||||
|
|
|
|||
|
|
@ -92,6 +92,17 @@
|
|||
<p>This is used to show your active projects on the leaderboard & current hacking activity on the dashboard.</p>
|
||||
<% if @user.github_uid.present? %>
|
||||
<p>✅ Your GitHub account is linked: <%= link_to "@#{@user.github_username}", "https://github.com/#{@user.github_username}", target: "_blank" %></p>
|
||||
<% if @user.github_access_token.present? %>
|
||||
<%= link_to "Relink GitHub Account", github_auth_path, data: { turbo: "false" }, role: "button" %>
|
||||
<%= link_to "Unlink GitHub Account", github_unlink_path,
|
||||
method: :delete,
|
||||
data: { confirm: "Are you sure? This will remove access to your GitHub data." },
|
||||
role: "button",
|
||||
class: "outline" %>
|
||||
<% else %>
|
||||
<p>⚠️ Your GitHub token has expired. Please relink your account.</p>
|
||||
<%= link_to "Relink GitHub Account", github_auth_path, data: { turbo: "false" }, role: "button" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "Link GitHub Account", github_auth_path, data: { turbo: "false" }, role: "button" %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ Rails.application.routes.draw do
|
|||
get "/auth/slack/callback", to: "sessions#create"
|
||||
get "/auth/github", to: "sessions#github_new", as: :github_auth
|
||||
get "/auth/github/callback", to: "sessions#github_create"
|
||||
delete "/auth/github/unlink", to: "sessions#github_unlink", as: :github_unlink
|
||||
post "/auth/email", to: "sessions#email", as: :email_auth
|
||||
post "/auth/email/add", to: "sessions#add_email", as: :add_email_auth
|
||||
get "/auth/token/:token", to: "sessions#token", as: :auth_token
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue