Skip to content

Commit

Permalink
feat: disable sgid pocdex login
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Nov 22, 2023
1 parent dcdf81c commit ea78539
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
52 changes: 32 additions & 20 deletions frontend/src/features/login/components/SgidLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
import { useForm } from 'react-hook-form'
import { useMutation } from 'react-query'

Check warning on line 2 in frontend/src/features/login/components/SgidLoginButton.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

'useMutation' is defined but never used
import { Flex, Link, Text, VStack } from '@chakra-ui/react'
import { Box, Flex, Link, Text, VStack } from '@chakra-ui/react'

import { SGID_VALID_ORG_PAGE } from '~shared/constants'

import { SingpassFullLogoSvgr } from '~assets/svgrs/singpass/SingpassFullLogoSvgr'
import { getSgidAuthUrl } from '~services/AuthService'
// import { getSgidAuthUrl } from '~services/AuthService'
import Button from '~components/Button'
import Tooltip from '~components/Tooltip'

export const SgidLoginButton = (): JSX.Element => {
const { formState } = useForm()

const handleLoginMutation = useMutation(getSgidAuthUrl, {
onSuccess: (data) => {
window.location.assign(data.redirectUrl)
},
})
// const handleLoginMutation = useMutation(getSgidAuthUrl, {
// onSuccess: (data) => {
// window.location.assign(data.redirectUrl)
// },
// })
return (
<VStack alignItems="start">
<Button
isFullWidth
isLoading={formState.isSubmitting}
type="submit"
color="primary"
onClick={() => handleLoginMutation.mutate()}
variant="outline"
<Tooltip
placement="top"
label="These are features specific to SG Government and not available on playground."
>
<Flex align="center" flexDirection="row">
<Text color="primary.500">Log in with </Text>
<SingpassFullLogoSvgr height="1.25rem" />
<Text color="primary.500"> app</Text>
</Flex>
</Button>
<Box width="100%">
{/* To prevent isDisabled swallowing the mouseover event for tooltip */}
<Button
isDisabled
isFullWidth
isLoading={formState.isSubmitting}
type="submit"
color="primary"
onClick={() => {
// no-op
}}
variant="outline"
>
<Flex align="center" flexDirection="row">
<Text color="primary.500">Log in with </Text>
<SingpassFullLogoSvgr height="1.25rem" />
<Text color="primary.500"> app</Text>
</Flex>
</Button>
</Box>
</Tooltip>
<Text>
For{' '}
<Link isExternal href={SGID_VALID_ORG_PAGE}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Router } from 'express'

import * as AdminFormController from '../../../../../modules/form/admin-form/admin-form.controller'
import { disabledOnPlayground } from '../../../../../utils/disabled-on-playground'

export const AdminFormsGoGovRouter = Router()

Expand All @@ -17,4 +18,4 @@ AdminFormsGoGovRouter.route('/:formId([a-fA-F0-9]{24})/gogov')
* @route POST /:formId/gogov
* @security session
*/
.post(AdminFormController.handleSetGoLinkSuffix)
.post(disabledOnPlayground, AdminFormController.handleSetGoLinkSuffix)
7 changes: 6 additions & 1 deletion src/app/routes/api/v3/auth/auth-sgid.routes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Router } from 'express'

import * as AuthSgidController from '../../../../modules/auth/sgid/auth-sgid.controller'
import { disabledOnPlayground } from '../../../../utils/disabled-on-playground'

export const AuthSGIDRouter = Router()

AuthSGIDRouter.get('/authurl', AuthSgidController.generateAuthUrl)
AuthSGIDRouter.get(
'/authurl',
disabledOnPlayground,
AuthSgidController.generateAuthUrl,
)

/**
* Receives the selected login details from Sgid
Expand Down

0 comments on commit ea78539

Please sign in to comment.