You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
Thanks so much for checking the gem out! 😄 I didn't have a Devise integration in mind originally, but I will definitely look into it and get back to you!
You're awesome for filling this need, and even more awesome for responding so kindly! I'm not a professional programmer and I've never done a Github pull request.
I don't know if this will help, here's how I modified my Rails project so Devise works with your gem.
The "right" way to do it in a gem is probably following the omniauth- gem framework, but alas, I had to get it working in less than an hour and your code helped me do that. So once again, THANK YOU SO MUCH!!
./db/migrate/add_omniauth_to_users.rb
class AddOmniauthToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :provider, :string
add_column :users, :uid, :string
add_column :users, :name, :string
add_column :users, :image, :text
end
end
./app/models/user.rb
class User < ApplicationRecord
def self.from_slack(auth)
i = auth.identity
user = User.where(provider: :slack, uid: i.unique_id).first_or_create do |user|
user.password = Devise.friendly_token[0, 20]
end
user.email = i.email
user.name = i.name # assuming the user model has a name
user.image = i.avatar # assuming the user model has an image
# If you are using confirmable and the provider(s) you use validate emails,
# uncomment the line below to skip the confirmation emails.
# user.skip_confirmation!
user.save if user.changed?
user
end
end
./app/controllers/users/sessions_controller.rb
class Users::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
include SlackSignIn::Authorization
# GET /users/sign_in
# This should DEFINITELY be somewhere else, but it's where I put it. I used /users/sign_in as the redirect path in Slack
def new
if slack_authorization.successful?
user = User.from_slack(slack_authorization)
sign_in user
redirect_to '/'
else
super
end
end
end
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Any plans to integrate this fantastic piece of work with Devise?
Gems intended for that (
omniauth-slack
) are pretty terrible.The text was updated successfully, but these errors were encountered: