Skip to content

Commit

Permalink
fix(sso-link-verification) redirecting the user from the place they t…
Browse files Browse the repository at this point in the history
…ried to login (#318)
  • Loading branch information
Athira001 authored Oct 14, 2021
1 parent 7817d89 commit ca437ca
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions app/isomorphic/components/molecules/forms/sign-up.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useState, useEffect } from "react";
import { func, string } from "prop-types";
import { connect } from "react-redux";
import { func, string, object } from "prop-types";
import { register, sendVerificationLink } from "@quintype/bridgekeeper-js";
import get from "lodash/get";
import { connect } from "react-redux";
import { parseUrl } from "query-string";

import { InputField } from "../../atoms/InputField";

import "./forms.m.css";

const SignUpBase = ({ onSignup, onLogin, isVerificationLinkflow }) => {
const SignUpBase = ({ onSignup, onLogin, qtConfig, currentPath }) => {
const [userInfo, setUserInfo] = useState({
name: "",
email: "",
Expand All @@ -18,6 +19,8 @@ const SignUpBase = ({ onSignup, onLogin, isVerificationLinkflow }) => {
const [verficationSuccessMessage, setSuccessMessage] = useState("");
const [userExists, setUserExists] = useState(false);
const [currentLocation, setCurrentLocation] = useState("/");
const isVerificationLinkflow = get(qtConfig, ["publisher-attributes", "is_verification_link_flow"], true);
const ssoLoginIsEnable = get(qtConfig, ["publisher-attributes", "sso_login", "is_enable"], false);

const signUpHandler = async e => {
e.preventDefault();
Expand Down Expand Up @@ -52,7 +55,12 @@ const SignUpBase = ({ onSignup, onLogin, isVerificationLinkflow }) => {
}

if (isVerificationLinkflow) {
sendVerificationLink(userInfo.email, currentLocation);
const params = parseUrl(currentPath);
const callbackUrl = ssoLoginIsEnable
? get(params, ["query", "callback_uri"]) ||
get(qtConfig, ["publisher-attributes", "sso_login", "callback_Url"], "")
: currentLocation;
sendVerificationLink(userInfo.email, callbackUrl);
!userExists &&
setSuccessMessage(
`We have sent an activation email to you at ${userInfo.email}. Please check your email inbox.`
Expand Down Expand Up @@ -127,11 +135,13 @@ SignUpBase.propTypes = {
onSignup: func,
setMember: func,
onLogin: func,
isVerificationLinkflow: string
qtConfig: object,
currentPath: string
};

const mapStateToProps = state => ({
isVerificationLinkflow: get(state, ["qt", "config", "publisher-attributes", "is_verification_link_flow"], true)
qtConfig: get(state, ["qt", "config"], {}),
currentPath: get(state, ["qt", "currentPath"], "")
});

export const SignUp = connect(mapStateToProps, null)(SignUpBase);

0 comments on commit ca437ca

Please sign in to comment.