strongmind-auth 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa3b415850df2aa96fc700cdd6f9062a2b08bd45013b3cf0eed7daface29b249
4
- data.tar.gz: f5b2460f7b9647a5ca78a077cb15fdd4ada4deec9283f4b13c25baee8cf4d1a1
3
+ metadata.gz: c354a11e582f73dbffa8303b9f62da41ba670ab4b149521bc449b21136721b97
4
+ data.tar.gz: 240af831cd266936721d98f8e8a0796cd7700d8722d8e2dcf7bc62e5b78d7f8c
5
5
  SHA512:
6
- metadata.gz: a1e37eb6d57253077830cf3d34364708b3ea823272ed095ae54e348e51ecc3c1b868977c1e3e53afc2670cd98f526d8faa835e69c8f2ae25c864bf32239b0ac0
7
- data.tar.gz: 65f17555dd2cad8787ab9855f424495311a9b289a87732a508f4e2b3d3a5a4384d05a9d6f03cb371a527e9087c55f80ae94f7370fcaaa284d8e4f2146e8ea700
6
+ metadata.gz: c2f44a55c2cece8baacf95d9cda467e4ab4d5c1a93cee41b0f1c7e9b7f4efce42111571c05ae303e8e46cedd31f6673b236f7a00d0dc5cb0262cd4ecc262f0e3
7
+ data.tar.gz: 9b5ed691d3d9e850f17fec2ba0af08012e046236c56efd37df46b1d0a3dd2dfc2a4f98caff8a42ab29f676d4861e65bf9b67d50fc206a4348a55e1f50dcf22c9
data/README.md CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  Ruby gem for authentication in a rails app
4
4
 
5
- ## Usage
5
+ ## Creating a new Rails app
6
6
 
7
- 1. `rails new app --css tailwind`
8
- 1. `cd app`
9
- 1. `bundle add strongmind-auth`
10
- 1. `rails g strongmind:install`
7
+ 1. Use [Repository Dashboard](https://repository-dashboard.strongmind.com/repositories/new) to create a new repository
8
+ with the rails-template.
9
+ 1. Navigate to the repo folder in a terminal and execute `rails g strongmind:install`
11
10
  1. Move app root to authenticated root in routes. Should look like this:
12
11
  ```ruby
13
12
  authenticated :user do
@@ -15,5 +14,5 @@ Ruby gem for authentication in a rails app
15
14
  end
16
15
  ```
17
16
  1. Create a new client in identity server and `IDENTITY_CLIENT_ID` and `IDENTITY_CLIENT_SECRET` values to .env file.
18
- 1. `rails dev:cache`
19
- 1. `bin/dev`
17
+ 1. Execute `rails dev:cache` to turn on caching in development.
18
+ 1. Execute `bin/dev`
@@ -0,0 +1,26 @@
1
+ require 'platform_sdk'
2
+
3
+ module StrongMindNav
4
+ extend ActiveSupport::Concern
5
+
6
+ def fetch_common_nav
7
+ begin
8
+ navbar = PlatformSdk::CommonNavFetcher.new(current_user, request).retrieve(menu_items)
9
+
10
+ @top_navbar_html = navbar[:top_navbar_html]
11
+ @bottom_navbar_html = navbar[:bottom_navbar_html]
12
+ @theme_css = navbar[:theme_css]
13
+ rescue PlatformSdk::CommonNavFetcher::TokenNotFoundError, PlatformSdk::CommonNavFetcher::UserNotFoundError
14
+ render 'logins/index'
15
+ rescue Faraday::TimeoutError
16
+ @top_navbar_html = render_to_string(partial: 'layouts/loading_navbar').html_safe
17
+ end
18
+ end
19
+
20
+ def menu_items
21
+ [
22
+ { name: 'Home', icon: 'fa-solid fa-house', path_method: :root_path }
23
+ ]
24
+ end
25
+
26
+ end
@@ -1,5 +1,6 @@
1
1
  class LoginsController < ApplicationController
2
2
  skip_before_action :authenticate_user!
3
+ skip_before_action :fetch_common_nav
3
4
 
4
5
  def index
5
6
  flash[:alert] = nil
@@ -3,6 +3,7 @@
3
3
  module Users
4
4
 
5
5
  class OmniauthCallbacksController < Devise::OmniauthCallbacksController
6
+ skip_before_action :fetch_common_nav
6
7
 
7
8
  def strongmind
8
9
  auth = request.env['omniauth.auth']
@@ -0,0 +1,30 @@
1
+ <a href="/" data-turbo="false">
2
+ <nav class="flex sm-top-nav">
3
+ <div class="flex-1 branding-container">
4
+ <img class="branding-logo-lg" src="https://prod-backpack-ui.strongmind.com/assets/images/sm-logo-2c-white.png"/>
5
+ <img class="branding-logo-sm" src="https://prod-backpack-ui.strongmind.com/assets/images/SMbulb.svg"/>
6
+ </div>
7
+
8
+ <div id="loading">
9
+ <canvas id="canvas" width="64" height="64"></canvas>
10
+
11
+ <script src="https://unpkg.com/@rive-app/canvas@2.9.3"></script>
12
+ <script>
13
+ const r = new rive.Rive({
14
+ src: "https://backpack.strongmind.com/assets/images/loader_dark_mode.riv",
15
+ canvas: document.getElementById("canvas"),
16
+ autoplay: true,
17
+ stateMachines: null,
18
+ onLoad: () => {
19
+ },
20
+ });
21
+ </script>
22
+ </div>
23
+
24
+ <div class="flex-1 justify-end sm-top-nav-controls">
25
+ <div class="profile-container">
26
+ <i class="fa-light fa-circle-user text-white fa-2xl"></i>
27
+ </div>
28
+ </div>
29
+ </nav>
30
+ </a>
@@ -11,9 +11,16 @@ module Strongmind
11
11
  copy_file "user.rb", "app/models/user.rb", force: true
12
12
  end
13
13
 
14
- def protect_app_files
14
+ def protect_app_files_and_add_nav
15
15
  inject_into_file "app/controllers/application_controller.rb", after: "class ApplicationController < ActionController::Base\n" do
16
- " before_action :authenticate_user!\n"
16
+ " include StrongMindNav\n before_action :authenticate_user!\n before_action :fetch_common_nav\n
17
+ # Implement the list of menu items for the application
18
+ # def menu_items
19
+ # [
20
+ # { name: 'Home', icon: 'fa-solid fa-house', path_method: :root_path }
21
+ # ]
22
+ # end"
23
+
17
24
  end
18
25
  end
19
26
 
@@ -51,6 +58,7 @@ devise_scope :user do
51
58
  def add_dotenv_file
52
59
  copy_file "env", ".env"
53
60
  end
61
+
54
62
  end
55
63
 
56
64
  end
@@ -1,5 +1,5 @@
1
1
  module Strongmind
2
2
  module Auth
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Belding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,13 +105,14 @@ files:
105
105
  - Rakefile
106
106
  - app/assets/config/strongmind_auth_manifest.js
107
107
  - app/assets/stylesheets/strongmind/auth/application.css
108
+ - app/controllers/concerns/strong_mind_nav.rb
108
109
  - app/controllers/logins_controller.rb
109
110
  - app/controllers/users/omniauth_callbacks_controller.rb
110
111
  - app/helpers/strongmind/auth/application_helper.rb
111
112
  - app/jobs/rails/auth/application_job.rb
112
113
  - app/mailers/rails/auth/application_mailer.rb
113
114
  - app/models/user_base.rb
114
- - app/views/layouts/strongmind/auth/application.html.erb
115
+ - app/views/layouts/_loading_navbar.html.erb
115
116
  - app/views/logins/index.html.erb
116
117
  - config/initializers/devise.rb
117
118
  - config/routes.rb
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Rails auth</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <%#= stylesheet_link_tag "strongmind/auth/application", media: "all" %>
9
- </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
14
- </body>
15
- </html>