Chore: Include avatar url in sign_in response (#501)
- include avatar url in sign_in response ( fixes #500 ) - fix circle ci builds
This commit is contained in:
parent
eb5185974a
commit
77473dc2aa
4 changed files with 54 additions and 2 deletions
|
@ -12,8 +12,8 @@ defaults: &defaults
|
||||||
# Specify service dependencies here if necessary
|
# Specify service dependencies here if necessary
|
||||||
# CircleCI maintains a library of pre-built images
|
# CircleCI maintains a library of pre-built images
|
||||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||||
- image: circleci/postgres:9.4
|
- image: circleci/postgres:alpine
|
||||||
- image: circleci/redis:5.0.7-alpine
|
- image: circleci/redis:alpine
|
||||||
environment:
|
environment:
|
||||||
- CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f
|
- CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,8 @@ class DeviseOverrides::SessionsController < ::DeviseTokenAuth::SessionsControlle
|
||||||
# Prevent session parameter from being passed
|
# Prevent session parameter from being passed
|
||||||
# Unpermitted parameter: session
|
# Unpermitted parameter: session
|
||||||
wrap_parameters format: []
|
wrap_parameters format: []
|
||||||
|
|
||||||
|
def render_create_success
|
||||||
|
render 'devise/auth.json'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
14
app/views/devise/auth.json.jbuilder
Normal file
14
app/views/devise/auth.json.jbuilder
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
json.data do
|
||||||
|
json.id @resource.id
|
||||||
|
json.provider @resource.provider
|
||||||
|
json.uid @resource.uid
|
||||||
|
json.name @resource.name
|
||||||
|
json.nickname @resource.nickname
|
||||||
|
json.email @resource.email
|
||||||
|
json.account_id @resource.account_id
|
||||||
|
json.pubsub_token @resource.pubsub_token
|
||||||
|
json.role @resource.role
|
||||||
|
json.inviter_id @resource.inviter_id
|
||||||
|
json.confirmed @resource.confirmed?
|
||||||
|
json.avatar_url @resource.avatar_url
|
||||||
|
end
|
34
spec/controllers/devise/session_controller_spec.rb
Normal file
34
spec/controllers/devise/session_controller_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Session', type: :request do
|
||||||
|
describe 'GET /sign_in' do
|
||||||
|
let!(:account) { create(:account) }
|
||||||
|
|
||||||
|
context 'when it is invalid credentials' do
|
||||||
|
it 'returns unauthorized' do
|
||||||
|
params = { email: 'invalid@invalid.com', password: 'invalid' }
|
||||||
|
|
||||||
|
post new_user_session_url,
|
||||||
|
params: params,
|
||||||
|
as: :json
|
||||||
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
expect(response.body).to include('Invalid login credentials')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when it is valid credentials' do
|
||||||
|
let!(:user) { create(:user, password: 'test1234', account: account) }
|
||||||
|
|
||||||
|
it 'returns successful auth response' do
|
||||||
|
params = { email: user.email, password: 'test1234' }
|
||||||
|
|
||||||
|
post new_user_session_url,
|
||||||
|
params: params,
|
||||||
|
as: :json
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(response.body).to include(user.email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue