This file contains hidden or 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
| module Admin | |
| class UsersController < Admin::ApplicationController | |
| def login_as_user | |
| @user = User.find(params[:id]) | |
| session[:user_id] = @user.id | |
| redirect_to root_path | |
| end | |
| end |
This file contains hidden or 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
| class ApplicationController < ActionController::Base | |
| protect_from_forgery with: :exception | |
| helper_method :current_user | |
| helper_method :current_admin_user | |
| def current_user | |
| @current_user ||= User.find_by(id: session[:user_id]) | |
| end |
This file contains hidden or 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
| module Admin | |
| class ApplicationController < Administrate::ApplicationController | |
| before_action :authenticate_admin | |
| helper_method :current_user | |
| def authenticate_admin | |
| if current_user.nil? || current_user.admin? == false | |
| flash[:alert] = 'You do not have authorization to access this page.' |
This file contains hidden or 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
| ... | |
| <div style="margin: 0 10px;"> | |
| <%= link_to( | |
| 'Log in as user', | |
| authenticate_as_user_admin_user_path(page.resource), | |
| method: :post, | |
| class: "button", | |
| )%> | |
| </div> |
This file contains hidden or 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
| <% if current_user %> | |
| <% if current_admin_user.present? && current_admin_user != current_user %> | |
| <h1><%= current_admin_user.email %> is logged in as <%= current_user.email %>.</h1> | |
| <% else %> | |
| <h1><%= current_user.email %> is logged in.</h1> | |
| <% end %> | |
| <ul> | |
| <li><%= link_to 'Admin', admin_root_path %></li> | |
| <li><%= link_to 'Log out', auth_logout_path, method: :post %></li> |
This file contains hidden or 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
| class Auth0Controller < ApplicationController | |
| def authentication | |
| redirect_to( | |
| "https://#{ENV.fetch('AUTH0_DOMAIN')}/authorize?" + | |
| "client_id=#{ENV.fetch('AUTH0_CLIENT_ID')}&" + | |
| "response_type=code&" + | |
| "redirect_uri=#{URI.encode(auth_callback_url)}" | |
| ) | |
| end | |
| end |
This file contains hidden or 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
| <script type="text/javascript"> | |
| const loadStylesheet = src => { | |
| if(document.createStylesheet) | |
| document.createStylesheet(src); | |
| else { | |
| const stylesheet = document.createElement('link'); | |
| stylesheet.href = src; | |
| stylesheet.type = 'text/css'; | |
| stylesheet.rel = 'stylesheet'; | |
| document.getElementsByTagName('head')[0].appendChild(stylesheet); |
This file contains hidden or 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
| @include-when-export url(https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic); | |
| @include-when-export url(https://fonts.googleapis.com/css?family=Raleway:600,400&subset=latin,latin-ext); | |
| @charset "UTF-8"; | |
| @font-face { | |
| font-family: 'TeXGyreAdventor'; | |
| font-style: normal; | |
| font-weight: normal; | |
| src: url(./gothic/texgyreadventor-regular.otf); | |
| } |
This file contains hidden or 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
| class FakeRedis | |
| attr_reader :counts, :vars | |
| def initialize(counts: {}, vars: {}) | |
| @counts = counts | |
| @vars = vars | |
| end | |
| def set(var, val) | |
| @vars[var] = val |
This file contains hidden or 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
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rails" |