Skip to content
Snippets Groups Projects

feat(login): new login flow (MIN-281)

Merged mateusz-winiarczyk requested to merge MIN-281-login-information into development
3 unresolved threads

Add new login flow - Design link

Flow: Login after authorization:

  • For "user": close login modal
  • For "curator/admin": show new dialog with options "Back to the map" and "Go to the admin panel"

For both users, the icon changes to "logged in"

Reopening login for logged-in user:

For "user":

  • Switch account -> back to login
  • Logout

For "curator/admin":

  • Go to the admin panel
  • Switch account -> back to login
  • Logout

Additionally, the login button has been removed in the overlay drawer at Marek's request

login

Closes MIN-281

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
5 import { projectIdSelector } from '@/redux/project/project.selectors';
6 import { Button } from '@/shared/Button';
7 import { useRouter } from 'next/router';
8 import React from 'react';
9
10 export const LoggedInMenuModal = (): React.ReactNode => {
11 const dispatch = useAppDispatch();
12 const router = useRouter();
13 const projectId = useAppSelector(projectIdSelector);
14
15 const closeLoggedInMenuModal = (): void => {
16 dispatch(closeModal());
17 };
18
19 const goToTheAdminPanel = (): void => {
20 router.push(`${ADMIN_PANEL_URL}?id=${projectId}`);
  • 11 import { hasPrivilege } from './user.utils';
    12
    13 const getUserRole = async (login: string): Promise<string> => {
    14 const response = await axiosInstance.get<UserPrivileges>(apiPath.userPrivileges(login), {
    15 withCredentials: true,
    16 });
    17
    18 const {
    19 data: { privileges },
    20 } = response;
    21
    22 if (hasPrivilege(privileges, 'IS_ADMIN')) {
    23 return USER_ROLE.ADMIN;
    24 }
    25 if (hasPrivilege(privileges, 'IS_CURATOR')) {
    26 return USER_ROLE.CURATOR;
  • 11 import { hasPrivilege } from './user.utils';
    12
    13 const getUserRole = async (login: string): Promise<string> => {
    14 const response = await axiosInstance.get<UserPrivileges>(apiPath.userPrivileges(login), {
    15 withCredentials: true,
    16 });
    17
    18 const {
    19 data: { privileges },
    20 } = response;
    21
    22 if (hasPrivilege(privileges, 'IS_ADMIN')) {
    23 return USER_ROLE.ADMIN;
    24 }
    25 if (hasPrivilege(privileges, 'IS_CURATOR')) {
    26 return USER_ROLE.CURATOR;
    • Comment on lines +22 to +26

      IMO it would be better to create hashmap function that would return role for privileges. In this case number of roles is small but imagine what will happen if there would be 5-6 roles.

    • Please register or sign in to reply
  • LGTM

    No RFCs due to lack of time, IMO there's no dangerous parts but some may need some improvement

  • Adrian Orłów approved this merge request

    approved this merge request

  • added 7 commits

    Compare with previous version

  • added 1 commit

    • 61b7eb6d - refactor(login): extract string to constant and add test for curator

    Compare with previous version

  • mateusz-winiarczyk reset approvals from @AdrianOrlow by pushing to the branch

    reset approvals from @AdrianOrlow by pushing to the branch

  • mentioned in commit c74e3377

  • Please register or sign in to reply
    Loading