Skip to content

Commit

Permalink
Merge pull request #21 from sparrowapp-dev/feat/16/implement-auth-bac…
Browse files Browse the repository at this point in the history
…kground

feat: add terms of service environment
  • Loading branch information
LordNayan authored Feb 28, 2024
2 parents 47dae2f + a4937e2 commit cb28167
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ VITE_API_URL="http://localhost:9000"
VITE_SPARROW_SUPPORT_EMAIL="support@example.dev"
VITE_SPARROW_OAUTH="http://localhost:9000/api/auth/google/callback"
VITE_ENABLE_MIX_PANEL="false"
VITE_MIX_PANEL_TOKEN=""
VITE_MIX_PANEL_TOKEN=""
VITE_TERMS_OF_SERVICE="https://example.dev/termsandconditions"
3 changes: 2 additions & 1 deletion src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const constants = {
WORKSPACE_LIMIT: 5,
API_LIMIT: 5,
SPARROW_OAUTH:import.meta.env.VITE_SPARROW_OAUTH,
SPARROW_SUPPORT_EMAIL:import.meta.env.VITE_SPARROW_SUPPORT_EMAIL
SPARROW_SUPPORT_EMAIL:import.meta.env.VITE_SPARROW_SUPPORT_EMAIL,
SPARROW_TERMS_OF_SERVICE: import.meta.env.VITE_TERMS_OF_SERVICE
};

export default constants;
7 changes: 7 additions & 0 deletions src/lib/utils/dto/auth-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ export interface resetPasswordPostBody {
email: string;
newPassword: string;
}

export interface RegisterUser {
email: string;
firstName: string;
lastName: string;
password: string;
}
//i will create different interface here
3 changes: 2 additions & 1 deletion src/pages/Auth/register-page/RegisterPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import SupportHelp from '$lib/components/help/SupportHelp.svelte';
import Oauth from '$lib/components/o-auth/Oauth.svelte';
import { notifications } from '$lib/components/toast-notification/ToastNotification';
import constants from '$lib/utils/constants';
export let id;
let isRegistered = false;
let redirectRules = {
Expand Down Expand Up @@ -372,7 +373,7 @@
}}
/>
<label data-tauri-drag-region class="form-check-label ms-2" for="tnsCheckbox"
>I agree to the <a href="/register" class="text-decoration-none text-primaryColor"
>I agree to the <a href={constants.SPARROW_TERMS_OF_SERVICE} target="_blank" class="text-decoration-none text-primaryColor"
>Terms of Service</a
></label
>
Expand Down
9 changes: 5 additions & 4 deletions src/pages/Auth/register-page/register-page.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { registerUser } from '$lib/services/auth.service';
import type { registerUserPostBody } from '$lib/utils/dto';
import type { RegisterUser, registerUserPostBody } from '$lib/utils/dto';
import { checkValidation, registrationSchema } from '$lib/utils/validation';
import { navigate } from 'svelte-navigator';

export const handleRegister = async (userData) => {
export const handleRegister = async (userData : RegisterUser) => {
const response = await registerUser({
email: userData.email,
name: userData.firstName + " " + userData.lastName,
name: userData.lastName ? userData.firstName + " " + userData.lastName : userData.firstName,
password: userData.password
});
return response;
};

export const handleRegisterValidation = async (userData) => {
export const handleRegisterValidation = async (userData: RegisterUser) => {

const { isError, errorObject } = await checkValidation(registrationSchema, userData);
if (isError) {
return errorObject;
Expand Down

0 comments on commit cb28167

Please sign in to comment.