Commit 036735c2 authored by Hannes's avatar Hannes
Browse files

Finished working on A6

parent 2679a08a
class User < ApplicationRecord
def self.find_or_create_with_omniauth(auth_hash)
# identify user by provider + uid
user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
user = find_or_create_by(uid: auth_hash['uid'])
# additional info about the user
# which info is available depends on provider + scope
......
......@@ -11,13 +11,16 @@
</h5>
<p class="list-group-item-text">Last Modified <%= time_ago_in_words board.last_change %> ago.</p>
<p class="list-group-item-text">
<% if current_user %>
<%= link_to 'Edit Board Settings', edit_board_path(board) %>,
<%= link_to 'Delete Board', board, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</p>
</li>
<% end %>
<% if current_user %>
<li class="list-group-item list-group-item-action">
<h5 class="list-group-item-heading">Add a <%= link_to 'New Board', new_board_path %></h5>
</li>
<% end %>
</div>
\ No newline at end of file
......@@ -20,9 +20,11 @@
<h4 class="card-title"><%= card.title %></h4>
<p class="card-text"><%= card.description %></p>
<div class="card-text">
<% if current_user %>
<%= render 'button_to_prev_status', card: card %>
<%= link_to 'Edit', edit_card_path(card) %>
<%= render 'button_to_next_status', card: card %>
<% end %>
</div>
</div>
</div>
......@@ -33,7 +35,9 @@
<div class="card-body">
<h4 class="card-title">New Card</h4>
<div class="card-text">
<% if current_user %>
<%= link_to 'Create', new_board_card_path(@board) %>
<% end %>
</div>
</div>
</div>
......
......@@ -14,9 +14,11 @@
<tr>
<td><%= card.title %></td>
<td><%= card.status %></td>
<td><%= link_to 'Show', card %></td>
<td><%= link_to 'Edit', edit_card_path(card) %></td>
<td><%= link_to 'Destroy', card, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% if current_user %>
<td><%= link_to 'Show', card %></td>
<td><%= link_to 'Edit', edit_card_path(card) %></td>
<td><%= link_to 'Destroy', card, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
</tr>
<% end %>
</tbody>
......@@ -24,4 +26,6 @@
<br>
<%= link_to 'New Card', new_card_path(@board) %>
<% if current_user %>
<%= link_to 'New Card', new_card_path(@board) %>
<% end %>
\ No newline at end of file
......@@ -20,5 +20,7 @@
<%= @card.board_id %>
</p>
<%= link_to 'Edit', edit_card_path(@card) %> |
<%= link_to 'Back', cards_path %>
<% if current_user %>
<%= link_to 'Edit', edit_card_path(@card) %> |
<%= link_to 'Back', cards_path %>
<% end %>
\ No newline at end of file
......@@ -19,10 +19,10 @@
Kanban Boards
</a>
<span class="navbar-text float-xs-right" style="padding-right: 20px">
<span class="navbar-text float-xs-right" style="padding-right: 20px; display:flex;">
<% if current_user %>
Logged in as <%= current_user %>
<%= button_to "Logout with FHS", logout_path %>
<p style="padding-right: 15px; margin: auto"> <%= current_user.name %> </p>
<%= button_to "Logout", logout_path, method: :get %>
<% else %>
<%= button_to "Login with FHS", "/auth/fhs/", method: :post, data: {turbo: "false"} %>
<% end %>
......
require 'fhs'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :FHS, ENV['FHAUTH_APPLICATION_UID'], ENV['FHAUTH_SECRET_KEY'], {
provider :FHS, "jYF3vxieRbELX7t2_o86Rr5r7On6D0STICyeY2dVAKE", 'IUXZ17rB_DErxkhppHRYUW3jI_tdUUDbikeGKbwrfyE', {
name: 'fhs',
scope: 'identity public'
}
end
OmniAuth.config.logger = Rails.logger
\ No newline at end of file
OmniAuth.config.logger = Rails.logger
# OAuth didn't work with environment variables!
# FHAUTH_APPLICATION_UID=jYF3vxieRbELX7t2_o86Rr5r7On6D0STICyeY2dVAKE
# FHAUTH_SECRET_KEY=IUXZ17rB_DErxkhppHRYUW3jI_tdUUDbikeGKbwrfyE
# heroku config:set FHAUTH_APPLICATION_UID=jYF3vxieRbELX7t2_o86Rr5r7On6D0STICyeY2dVAKE
# heroku config:set FHAUTH_SECRET_KEY=IUXZ17rB_DErxkhppHRYUW3jI_tdUUDbikeGKbwrfyE
\ No newline at end of file
class AddUidToUser < ActiveRecord::Migration[6.1]
def change
add_column :users, :uid, :string
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_01_01_135444) do
ActiveRecord::Schema.define(version: 2022_01_01_145334) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -35,6 +35,7 @@ ActiveRecord::Schema.define(version: 2022_01_01_135444) do
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "uid"
end
add_foreign_key "cards", "boards"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment