fix(ui): eliminate username logic from signIn process (#10131)

* fix(ui): eliminate username logic from signIn process

* fix failing cypress

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
This commit is contained in:
Chirag Madlani 2023-02-08 20:50:31 +05:30 committed by GitHub
parent b62f97f27b
commit fe03e51cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 22 deletions

View File

@ -62,26 +62,30 @@ describe('Login flow should work properly', () => {
// Login with the created user // Login with the created user
// login(CREDENTIALS.email, CREDENTIALS.password); login(CREDENTIALS.email, CREDENTIALS.password);
// cy.goToHomePage(); cy.goToHomePage();
// cy.url().should('eq', `${BASE_URL}/my-data`); cy.url().should('eq', `${BASE_URL}/my-data`);
// //Verify user profile // Verify user profile
// cy.get('[data-testid="avatar"]').first().should('be.visible').trigger('mouseover').click(); cy.get('[data-testid="avatar"]')
.first()
.should('be.visible')
.trigger('mouseover')
.click();
// cy.get('[data-testid="user-name"]') cy.get('[data-testid="user-name"]')
// .should('be.visible') .should('be.visible')
// .invoke('text') .invoke('text')
// .should('contain', `${CREDENTIALS.firstName}${CREDENTIALS.lastName}`); .should('contain', `${CREDENTIALS.firstName}${CREDENTIALS.lastName}`);
// interceptURL('GET', 'api/v1/users/name/*', 'getUserPage'); interceptURL('GET', 'api/v1/users/name/*', 'getUser');
// cy.get('[data-testid="user-name"]') cy.get('[data-testid="user-name"]')
// .should('be.visible') .should('be.visible')
// .click({ force: true }); .click({ force: true });
// verifyResponseStatusCode('@getUserPage', 200); verifyResponseStatusCode('@getUser', 200);
// cy.get('[data-testid="left-panel"]').should( cy.get('[data-testid="left-panel"]').should(
// 'contain', 'contain',
// `${CREDENTIALS.firstName}${CREDENTIALS.lastName}` `${CREDENTIALS.firstName}${CREDENTIALS.lastName}`
// ); );
}); });
it('Signin using invalid credentials', () => { it('Signin using invalid credentials', () => {

View File

@ -80,7 +80,7 @@ Cypress.Commands.add('loginByGoogleApi', () => {
Cypress.Commands.add('goToHomePage', () => { Cypress.Commands.add('goToHomePage', () => {
interceptURL('GET', '/api/v1/system/entities/count', 'count'); interceptURL('GET', '/api/v1/system/entities/count', 'count');
interceptURL('GET', '/api/v1/feed*', 'feed'); interceptURL('GET', '/api/v1/feed*', 'feed');
interceptURL('GET', '/api/v1/users/name/*?fields=*', 'userProfile'); interceptURL('GET', '/api/v1/users/*?fields=*', 'userProfile');
cy.get('[data-testid="whats-new-dialog"]') cy.get('[data-testid="whats-new-dialog"]')
.should('exist') .should('exist')
.then(() => { .then(() => {

View File

@ -34,7 +34,7 @@ import React, {
import { useHistory, useLocation } from 'react-router-dom'; import { useHistory, useLocation } from 'react-router-dom';
import axiosClient from 'rest/index'; import axiosClient from 'rest/index';
import { fetchAuthenticationConfig, fetchAuthorizerConfig } from 'rest/miscAPI'; import { fetchAuthenticationConfig, fetchAuthorizerConfig } from 'rest/miscAPI';
import { getLoggedInUser, getUserByName, updateUser } from 'rest/userAPI'; import { getLoggedInUser, updateUser } from 'rest/userAPI';
import appState from '../../../AppState'; import appState from '../../../AppState';
import { NO_AUTH } from '../../../constants/auth.constants'; import { NO_AUTH } from '../../../constants/auth.constants';
import { REDIRECT_PATHNAME, ROUTES } from '../../../constants/constants'; import { REDIRECT_PATHNAME, ROUTES } from '../../../constants/constants';
@ -46,7 +46,6 @@ import jsonData from '../../../jsons/en';
import { import {
extractDetailsFromToken, extractDetailsFromToken,
getAuthConfig, getAuthConfig,
getNameFromEmail,
getUrlPathnameExpiry, getUrlPathnameExpiry,
getUserManagerConfig, getUserManagerConfig,
isProtectedRoute, isProtectedRoute,
@ -329,7 +328,7 @@ export const AuthProvider = ({
authConfig?.provider === AuthType.Basic authConfig?.provider === AuthType.Basic
? userAPIQueryFields + ',' + isEmailVerifyField ? userAPIQueryFields + ',' + isEmailVerifyField
: userAPIQueryFields; : userAPIQueryFields;
getUserByName(getNameFromEmail(user.profile.email), fields) getLoggedInUser(fields)
.then((res) => { .then((res) => {
if (res) { if (res) {
const updatedUserData = getUserDataFromOidc(res, user); const updatedUserData = getUserDataFromOidc(res, user);