diff --git a/README.md b/README.md index 998949a..64638c1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ This is a boilerplate to build your next SaaS product. It's a RubyOnRails 6 back This boilerplate works like a charm with the following gems: - pg - devise +- devise_invitable - graphql - graphql-auth - graphql-errors @@ -84,7 +85,12 @@ The app uses a PostgreSQL database. It implements the connector with the gem `pg ### 2. Authentication The app uses [devise](https://github.com/plataformatec/devise)'s logic for authentication. For graphQL API we use the JWT token, but to access the rails_admin backend we use standard devise views, but registration is excluded. -Change devise settins under `config/initializers/devise.rb` and `config/initializers/graphql_auth.rb`. +Change devise settings under `config/initializers/devise.rb` and `config/initializers/graphql_auth.rb`. + +#### Invitations +Admins of a company can invite new users. The process is handled with `devise_invitable`. We added a `inviteUser` and `acceptInvite` mutation to handle this process via graphql. + +Like in the reset password process we redirect the users to the frontend domain and not to backend. ### 3. JSON Web Token diff --git a/app/controllers/auth/invitations_controller.rb b/app/controllers/auth/invitations_controller.rb index a050e1b..05b1b01 100644 --- a/app/controllers/auth/invitations_controller.rb +++ b/app/controllers/auth/invitations_controller.rb @@ -3,12 +3,10 @@ module Auth # Custom passwords controller class InvitationsController < Devise::InvitationsController - # GET /resource/invitation/accept?invitation_token=abcdef # redirect user to front end to finish invitation def edit redirect_to "http://#{ENV['CLIENT_URL']}/users/invitation/accept?invitation_token=#{params[:invitation_token]}" end - end end diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index a5abc67..f80514b 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# rubocop:disable Layout/LineLength module Auth # Custom passwords controller class PasswordsController < Devise::PasswordsController @@ -9,4 +10,5 @@ def edit redirect_to "http://#{ENV['CLIENT_URL']}/users/password/edit?reset_password_token=#{params[:reset_password_token]}" end end -end \ No newline at end of file +end +# rubocop:enable Layout/LineLength diff --git a/config/locales/devise_invitable.en.yml b/config/locales/devise/invitable/en.yml similarity index 100% rename from config/locales/devise_invitable.en.yml rename to config/locales/devise/invitable/en.yml