Skip to content

Commit

Permalink
CPF Fixed issues with user creation flow through frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubKramp committed Sep 19, 2024
1 parent e61dcd2 commit b28e16a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Paste the contents of the seed.sql file and hit 'Run'.
Users can be added to the app through various methods:

1. **Supabase Panel**: Go to `localhost:8080` to create a user directly in the Supabase dashboard - authentication tab.
2. **Directly from a Browser**: Go to `localhost:8080/cpf/auth` to create a user via a authentication flow.
2. **Directly from a Browser**: Go to `localhost:8080/cpf/auth` to create a user via a authentication flow. Going forward we will probably get rid of this feature and focus on single sign on.
3. **Add Employee flow**: Employees can be added through the dashboard at `localhost:8080/cpf/people/add-new`. The default password is `password`.

### Automated Backend Processes
Expand Down
19 changes: 16 additions & 3 deletions frontend/src/actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export async function login(formData: FormData) {
}

export async function signup(formData: FormData) {
const supabase = createClient();
const supabase = createSupabaseClient(process.env.NEXT_PUBLIC_SUPABASE_SERVER_URL!, process.env.SERVICE_ROLE_KEY!, {
auth: {
autoRefreshToken: false,
persistSession: false,
},
});

// type-casting here for convenience
// in practice, you should validate your inputs
Expand All @@ -42,12 +47,20 @@ export async function signup(formData: FormData) {
password: formData.get('password') as string,
};

const { error } = await supabase.auth.signUp(data);

const { error } = await supabase.auth.admin.createUser({
email: data['email'],
email_confirm: true,
password: data['password'],
user_metadata: {
first_name: 'First Name',
last_name: 'Last Name'
},
});
if (error) {
redirect('/error');
}


revalidatePath('/');
redirect('/');
}
Expand Down
5 changes: 1 addition & 4 deletions seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ INSERT INTO band_bucket (band_id, bucket_slug) VALUES
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 23), 'cross_platform_frontend'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 35), 'security'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 35), 'algorithmic_knowledge'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 35), 'releases_ci_cd'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 50), 'releases_ci_cd2'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 55), 'releases_ci_cd3'),
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 60), 'releases_ci_cd4');
((SELECT band_id FROM band WHERE ladder_slug = 'frontend' AND threshold = 35), 'releases_ci_cd');
-- Insert advancement_level
INSERT INTO advancement_level (bucket_slug, advancement_level, description) VALUES
Expand Down

0 comments on commit b28e16a

Please sign in to comment.