Skip to content
Snippets Groups Projects
Unverified Commit 3f10582f authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Mark external accounts as verified (#4129)

* Mark external accounts as verified

* test
parent 61c614e4
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,8 @@ class ExternalController < ApplicationController
user_info = {
name: credentials['info']['name'],
email: credentials['info']['email'],
language: extract_language_code(credentials['info']['locale'])
language: extract_language_code(credentials['info']['locale']),
verified: true
}
user = User.find_or_create_by!(external_id: credentials['uid'], provider:) do |u|
......
# frozen_string_literal: true
class BackfillVerified < ActiveRecord::Migration[7.0]
def up
User.where.not(external_id: nil).update_all(verified: true) # rubocop:disable Rails/SkipsModelValidations
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
DataMigrate::Data.define(version: 20221003201116)
DataMigrate::Data.define(version: 20221115190918)
......@@ -49,6 +49,14 @@ RSpec.describe ExternalController, type: :controller do
expect(User.find_by(email: OmniAuth.config.mock_auth[:openid_connect][:info][:email]).role).to eq(role)
end
it 'marks the user as verified' do
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]
get :create_user, params: { provider: 'openid_connect' }
expect(User.find_by(email: OmniAuth.config.mock_auth[:openid_connect][:info][:email]).verified?).to be true
end
context 'redirect' do
it 'redirects to the location cookie if the format is valid' do
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment