mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
clean up
This commit is contained in:
parent
b0e474677e
commit
343d7db3c0
4 changed files with 4 additions and 71 deletions
|
@ -13,6 +13,7 @@ NX_AUTH0_CLIENT_SECRET=
|
|||
AUTH0_DEPLOY_CLIENT_SECRET=
|
||||
POSTMARK_SMTP_PASS=
|
||||
NX_SESSION_SECRET=
|
||||
AUTH_SECRET=
|
||||
|
||||
# If you want to test any code that utilizes the AWS SDK locally, add temporary STAGING credentials (can be retrieved from SSO dashboard)
|
||||
AWS_ACCESS_KEY_ID=
|
||||
|
|
|
@ -24,7 +24,7 @@ export const authOptions = {
|
|||
},
|
||||
session: {
|
||||
strategy: 'jwt' as SessionStrategy,
|
||||
maxAge: 14 * 24 * 60 * 60, // 30 Days
|
||||
maxAge: 7 * 24 * 60 * 60, // 7 Days
|
||||
},
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
|
@ -43,25 +43,19 @@ export const authOptions = {
|
|||
})
|
||||
.safeParse(credentials)
|
||||
|
||||
console.log("here's the credentials", parsedCredentials)
|
||||
|
||||
if (parsedCredentials.success) {
|
||||
const { name, email, password } = parsedCredentials.data
|
||||
|
||||
console.log('Hitting endpoint to get user', email)
|
||||
const { data } = await axios.get(`/auth-users`, {
|
||||
params: { email: email },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
|
||||
// TODO: use superjson to parse this more cleanly
|
||||
const user = data.data['json']
|
||||
|
||||
console.log('here is the user', user)
|
||||
|
||||
if (!user) {
|
||||
console.log('User does not exist, creating user')
|
||||
const hashedPassword = await bcrypt.hash(password, 10)
|
||||
console.log('Hitting endpoint to create user', name, email, hashedPassword)
|
||||
const { data } = await axios.post('/auth-users', {
|
||||
name,
|
||||
email,
|
||||
|
|
|
@ -32,10 +32,6 @@ module.exports = merge(designSystemConfig, {
|
|||
wave: '3 wave 0.6s ease-in-out',
|
||||
float: 'float 4s infinite linear',
|
||||
},
|
||||
backgroundImage: {
|
||||
'login-background':
|
||||
'radial-gradient(100% 100% at clamp(20%, calc(30% + var(--mx) * 0.05), 40%) clamp(50%, calc(50% + var(--my) * 0.05), 60%), #4361EE33 0%, #16161Af4 120%)',
|
||||
},
|
||||
typography: () => {
|
||||
const { white, gray, cyan } = designSystemConfig.theme.colors
|
||||
return {
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
import type { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query'
|
||||
import type { SharedType } from '@maybe-finance/shared'
|
||||
import type { AxiosInstance } from 'axios'
|
||||
import Axios from 'axios'
|
||||
import * as Sentry from '@sentry/react'
|
||||
import { useMemo } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'react-hot-toast'
|
||||
import { DateTime } from 'luxon'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useAxiosWithAuth } from '../hooks/useAxiosWithAuth'
|
||||
|
||||
const AuthUserApi = (axios: AxiosInstance) => ({
|
||||
|
@ -14,37 +9,6 @@ const AuthUserApi = (axios: AxiosInstance) => ({
|
|||
const { data } = await axios.get<SharedType.AuthUser>(`/auth-users/${email}`)
|
||||
return data
|
||||
},
|
||||
|
||||
async update(userData: SharedType.UpdateUser) {
|
||||
const { data } = await axios.put<SharedType.User>('/users', userData)
|
||||
return data
|
||||
},
|
||||
|
||||
async get() {
|
||||
const { data } = await axios.get<SharedType.User>('/users')
|
||||
return data
|
||||
},
|
||||
|
||||
async delete() {
|
||||
return axios.delete('/users', { data: { confirm: true } })
|
||||
},
|
||||
|
||||
async updateOnboarding(input: {
|
||||
flow: SharedType.OnboardingFlow
|
||||
updates: { key: string; markedComplete: boolean }[]
|
||||
markedComplete?: boolean
|
||||
}) {
|
||||
const { data } = await axios.put<SharedType.User>('/users/onboarding', input)
|
||||
return data
|
||||
},
|
||||
|
||||
async changePassword(newPassword: SharedType.PasswordReset) {
|
||||
const { data } = await axios.put<
|
||||
SharedType.PasswordReset,
|
||||
SharedType.ApiResponse<{ success: boolean; error?: string }>
|
||||
>('/users/change-password', newPassword)
|
||||
return data
|
||||
},
|
||||
})
|
||||
|
||||
const staleTimes = {
|
||||
|
@ -54,35 +18,13 @@ const staleTimes = {
|
|||
}
|
||||
|
||||
export function useAuthUserApi() {
|
||||
const queryClient = useQueryClient()
|
||||
const { axios } = useAxiosWithAuth()
|
||||
const api = useMemo(() => AuthUserApi(axios), [axios])
|
||||
|
||||
const useGetByEmail = (email: string) =>
|
||||
useQuery(['auth-users', email], () => api.getByEmail(email), { staleTime: staleTimes.user })
|
||||
|
||||
const useUpdateOnboarding = (
|
||||
options?: UseMutationOptions<
|
||||
SharedType.User,
|
||||
unknown,
|
||||
{
|
||||
flow: SharedType.OnboardingFlow
|
||||
updates: { key: string; markedComplete: boolean }[]
|
||||
markedComplete?: boolean
|
||||
}
|
||||
>
|
||||
) =>
|
||||
useMutation(api.updateOnboarding, {
|
||||
onSettled: () => queryClient.invalidateQueries(['users', 'onboarding']),
|
||||
...options,
|
||||
})
|
||||
|
||||
const useDelete = (options?: UseMutationOptions<{}, unknown, any>) =>
|
||||
useMutation(api.delete, options)
|
||||
|
||||
return {
|
||||
useGetByEmail,
|
||||
useUpdateOnboarding,
|
||||
useDelete,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue