Get code and token from Azure AD and store it to the DB

This commit is contained in:
Bilal
2020-08-12 13:52:22 +02:00
parent eb7f8f1a43
commit 0cc3b2bd62
9 changed files with 171 additions and 26 deletions

View File

@@ -5,6 +5,16 @@ class CallbacksController < ApplicationController
skip_before_action :verify_authenticity_token
def create
render plain: params.inspect
token_data = request.env['omniauth.auth'][:credentials]
current_user&.tap do |user|
user.microsoft_access_token = token_data.token
user.microsoft_refresh_token = token_data.refresh_token
user.microsoft_token_expires_at = token_data.expires_at # Expiration time is returned in seconds
user.save
end
redirect_to profile_path
end
end