File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
components/pages/auth/register Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,15 @@ const register = async (userData: {
4747 throw new Error ( "User data can't be saved properly" ) ;
4848 }
4949
50- const createVerify = await account . createVerification (
51- `${ process . env . NEXT_PUBLIC_BASE_URL } /verify` ,
52- ) ;
53-
54- if ( ! createVerify ) {
55- throw new Error ( "Error sending verification email" ) ;
50+ // send verification email in production mode
51+ if ( process . env . NODE_ENV === "production" ) {
52+ const createVerify = await account . createVerification (
53+ `${ process . env . NEXT_PUBLIC_BASE_URL } /verify` ,
54+ ) ;
55+
56+ if ( ! createVerify ) {
57+ throw new Error ( "Error sending verification email" ) ;
58+ }
5659 }
5760
5861 return dbData ;
@@ -245,7 +248,10 @@ const saveDataToDatabase = async (session: any) => {
245248 const resp = await db . createDocument ( palettegramDB , usersCollection , ID . unique ( ) , {
246249 email : session . email ,
247250 fullName : session . name ,
248- isVerified : session . emailVerification ,
251+ isVerified :
252+ process . env . NODE_ENV === "development"
253+ ? true // user verified by default in dev environment
254+ : session . emailVerification ,
249255 accountId : session . $id ,
250256 username : session ?. prefs ?. username ,
251257 avatarURL : avatar ,
Original file line number Diff line number Diff line change @@ -89,8 +89,13 @@ export default function RegisterComponent() {
8989 dispatch ( saveUserToStore ( payload ) ) ;
9090
9191 setIsLoading ( false ) ;
92- toastify ( "Register Successful. Please check your email to verify" , "success" ) ;
93- router . push ( "/verify" ) ;
92+ if ( process . env . NODE_ENV === "production" ) {
93+ toastify ( "Register Successful. Please check your email to verify" , "success" ) ;
94+ router . push ( "/verify" ) ;
95+ } else {
96+ toastify ( "Register Successful" , "success" ) ;
97+ router . push ( "/feed" ) ;
98+ }
9499 } catch ( error : any ) {
95100 setIsLoading ( false ) ;
96101
You can’t perform that action at this time.
0 commit comments