-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add favicon * fix creating collaborator account * update primo - symbol error handling * fix site previews, update primo
- Loading branch information
1 parent
084090b
commit 29e9dc8
Showing
10 changed files
with
98 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
import { json } from '@sveltejs/kit'; | ||
import { json } from '@sveltejs/kit' | ||
import supabase_admin from '$lib/supabase/admin' | ||
|
||
export async function POST({ request }) { | ||
const {url, site = null, server_invitation, role, email} = await request.json(); | ||
const { | ||
url, | ||
site = null, | ||
server_invitation, | ||
role, | ||
email, | ||
} = await request.json() | ||
|
||
const { data, error } = await supabase_admin.auth.admin.inviteUserByEmail(email, { redirectTo: `${url}/auth/set-password?email=${email}` }) | ||
const { data, error } = await supabase_admin.auth.admin.inviteUserByEmail( | ||
email, | ||
{ redirectTo: `${url}/auth/set-password?email=${email}` } | ||
) | ||
|
||
if (!error) { | ||
await supabase_admin.from('users').insert({ | ||
id: data.user.id, | ||
email: data.user.email, | ||
}) | ||
|
||
await supabase_admin | ||
.from('users') | ||
.insert({ | ||
id: data.user.id, | ||
email: data.user.email | ||
}) | ||
|
||
// Add to 'server_members' or 'collaborators' | ||
const {error} = server_invitation ? | ||
await supabase_admin.from('server_members').insert({ user: data.user.id, role }) : | ||
await supabase_admin.from('collaborators').insert({ site, user: data.user.id, role }) | ||
const { error } = server_invitation | ||
? await supabase_admin | ||
.from('server_members') | ||
.insert({ user: data.user.id, role }) | ||
: await supabase_admin | ||
.from('collaborators') | ||
.insert({ site, user: data.user.id, role }) | ||
|
||
console.error(error) | ||
return json({success: !error, error: error?.message}); | ||
return json({ success: !error, error: error?.message }) | ||
} else { | ||
console.error(error) | ||
return json({success: false, error: error.message}); | ||
return json({ success: false, error: error.message }) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import supabase_admin from '$lib/supabase/admin' | ||
import {redirect} from '@sveltejs/kit' | ||
import { redirect } from '@sveltejs/kit' | ||
|
||
/** @type {import('./$types').Actions} */ | ||
export const actions = { | ||
default: async ({ request, locals }) => { | ||
const { session } = locals | ||
default: async ({ request, locals: { supabase } }) => { | ||
const form_data = await request.formData() | ||
const email = form_data.get('email') | ||
const password = form_data.get('password') | ||
|
||
const form_data = await request.formData(); | ||
const email = form_data.get('email'); | ||
const password = form_data.get('password'); | ||
const { data } = await supabase_admin | ||
.from('users') | ||
.select('id') | ||
.eq('email', email) | ||
.single() | ||
|
||
const { data, error } = await supabase_admin.auth.admin.updateUserById( | ||
session.user.id, | ||
{ password } | ||
) | ||
const { error } = await supabase_admin.auth.admin.updateUserById(data.id, { | ||
password, | ||
}) | ||
|
||
await supabase_admin.from('invitations').delete().match({ email }) | ||
|
||
if (!error) { | ||
await supabase.auth.signInWithPassword({ email, password }) | ||
throw redirect(303, '/') | ||
} | ||
|
||
return { success: !error, error }; | ||
} | ||
}; | ||
return { success: !error, error } | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters