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/
.idea/
# PyCharm
# 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

View file

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

View file

@ -122,6 +122,7 @@ interface NewAccountBody {
email: string;
password: string;
org_slug: string;
org_id:string;
}
export async function signup(body: NewAccountBody): Promise<any> {
@ -134,6 +135,7 @@ export async function signup(body: NewAccountBody): Promise<any> {
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;
}