Merge pull request #136 from nvrthles/dev

NextJS client side sign up URL not including using organization
This commit is contained in:
Badr B 2023-12-30 17:35:05 +01:00 committed by GitHub
commit 01e6d6d171
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

2
apps/api/.gitignore vendored
View file

@ -162,7 +162,7 @@ dmypy.json
# Cython debug symbols # Cython debug symbols
cython_debug/ cython_debug/
.idea/
# PyCharm # PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore

View file

@ -61,6 +61,7 @@ function SignUpClient(props: SignUpClientProps) {
const formik = useFormik({ const formik = useFormik({
initialValues: { initialValues: {
org_slug: props.org?.slug, org_slug: props.org?.slug,
org_id: props.org?.id,
email: '', email: '',
password: '', password: '',
username: '', username: '',
@ -70,6 +71,8 @@ function SignUpClient(props: SignUpClientProps) {
}, },
validate, validate,
onSubmit: async values => { onSubmit: async values => {
setError('')
setMessage('')
setIsSubmitting(true); setIsSubmitting(true);
let res = await signup(values); let res = await signup(values);
let message = await res.json(); let message = await res.json();
@ -81,6 +84,7 @@ function SignUpClient(props: SignUpClientProps) {
else if (res.status == 401 || res.status == 400 || res.status == 404 || res.status == 409) { else if (res.status == 401 || res.status == 400 || res.status == 404 || res.status == 409) {
setError(message.detail); setError(message.detail);
setIsSubmitting(false); setIsSubmitting(false);
} }
else { else {
setError("Something went wrong"); setError("Something went wrong");

View file

@ -122,6 +122,7 @@ interface NewAccountBody {
email: string; email: string;
password: string; password: string;
org_slug: string; org_slug: string;
org_id:string;
} }
export async function signup(body: NewAccountBody): Promise<any> { export async function signup(body: NewAccountBody): Promise<any> {
@ -134,6 +135,7 @@ export async function signup(body: NewAccountBody): Promise<any> {
redirect: "follow", redirect: "follow",
}; };
const res = await fetch(`${getAPIUrl()}users/?org_slug=${body.org_slug}`, requestOptions); const res = await fetch(`${getAPIUrl()}users/${body.org_id}`, requestOptions);
return res; return res;
} }