Skip to content

Instantly share code, notes, and snippets.

View NicholusMuwonge's full-sized avatar
💭
Job Hunting

nicks-bro NicholusMuwonge

💭
Job Hunting
View GitHub Profile
# Api Controller to handle our call backs
require 'json'
class Api::V1::SocialAuthController < ApplicationController
def authenticate_social_auth_user
# params is the response I receive from the client with the data from the provider about the user
@user = User.signin_or_create_from_provider(params) # this method add a user who is new or logins an old one
if @user.persisted?
# I log the user in at this point
sign_in(@user)
# after user is loggedIn, I generate a new_token here
namespace :api, defaults: { format: :json } do
namespace :v1 do
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks] # add this and overide the omniauth callbacks
post 'social_auth/callback', to: 'social_auth_controller#authenticate_social_auth_user' # this is the line where we add our routes
end
end
import React from "react";
import { GoogleAPI, GoogleLogin, GoogleLogout } from "react-google-oauth";
import FacebookLogin from 'react-facebook-login';
function App() {
return (
<div className="App">
<div className="App-header">