Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add SSO button to sign in

Blue Mouse4a78b00e34d6
diff --git a/src/pages/Auth/Signin/Signin.container.tsx b/src/pages/Auth/Signin/Signin.container.tsx
index 005e3db81..e737ade5b 100644
--- a/src/pages/Auth/Signin/Signin.container.tsx
+++ b/src/pages/Auth/Signin/Signin.container.tsx
@@ -11,6 +11,7 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
login: (data: {
email: string,
password: string,
+ dontRemember: boolean
}, callback: () => void) => {
dispatch(sagaActions.loginAsync(data, callback))
},
@@ -24,6 +25,10 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
message: error,
}))
},
+ authSSO: (dontRemember: boolean, t: (key: string) => string, callback: (res: any) => void) => {
+ console.log('dispatching authSSO')
+ dispatch(sagaActions.authSSO(dontRemember, t, callback))
+ },
})
export default connect(null, mapDispatchToProps)(Signin)
diff --git a/src/pages/Auth/Signin/Signin.tsx b/src/pages/Auth/Signin/Signin.tsx
index 234d7bc2b..2b2fea694 100644
--- a/src/pages/Auth/Signin/Signin.tsx
+++ b/src/pages/Auth/Signin/Signin.tsx
@@ -7,6 +7,7 @@ import _isEmpty from 'lodash/isEmpty'
import _isString from 'lodash/isString'
import Title from 'components/Title'
+import GoogleAuth from 'components/GoogleAuth'
import { withAuthentication, auth } from 'hoc/protected'
import routes from 'routes'
import Input from 'ui/Input'
@@ -21,7 +22,10 @@ import { submit2FA } from 'api'
import { setAccessToken } from 'utils/accessToken'
import { setRefreshToken } from 'utils/refreshToken'
-const Signin = ({ login, loginSuccess, loginFailed }: {
+// TODO: ADD & USE INTERFACE ISignin
+const Signin = ({
+ login, loginSuccess, loginFailed, authSSO,
+}: {
login: (data: {
email: string,
password: string,
@@ -29,6 +33,7 @@ const Signin = ({ login, loginSuccess, loginFailed }: {
}, callback: (result: boolean, twoFARequired: boolean) => void) => void,
loginSuccess: (user: IUser) => void,
loginFailed: (error: string) => void,
+ authSSO: any, // TODO add types
}): JSX.Element => {
const { t }: {
t: (key: string, optinions?: {
@@ -85,6 +90,13 @@ const Signin = ({ login, loginSuccess, loginFailed }: {
setTwoFACodeError(null)
}
+ const loginCallback = (result: boolean, twoFARequired: boolean) => {
+ if (!result) {
+ setIsLoading(false)
+ setIsTwoFARequired(twoFARequired)
+ }
+ }
+
const onSubmit = (data: {
email: string,
password: string,
@@ -92,12 +104,7 @@ const Signin = ({ login, loginSuccess, loginFailed }: {
}) => {
if (!isLoading) {
setIsLoading(true)
- login(data, (result, twoFARequired) => {
- if (!result) {
- setIsLoading(false)
- setIsTwoFARequired(twoFARequired)
- }
- })
+ login(data, loginCallback)
}
}
@@ -247,6 +254,7 @@ const Signin = ({ login, loginSuccess, loginFailed }: {
{t('auth.signin.button')}
</Button>
</div>
+ <GoogleAuth setIsLoading={setIsLoading} authSSO={authSSO} callback={loginCallback} dontRemember={form.dontRemember} />
</form>
</div>
</Title>
@@ -257,6 +265,7 @@ Signin.propTypes = {
login: PropTypes.func.isRequired,
loginSuccess: PropTypes.func.isRequired,
loginFailed: PropTypes.func.isRequired,
+ authSSO: PropTypes.func.isRequired,
}
export default memo(withAuthentication(Signin, auth.notAuthenticated))