aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/register/+page.server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-15 23:02:29 -0800
committerAdam Soltys <[email protected]>2023-11-15 23:02:29 -0800
commitb466b3d39c3b9ec792ef924c7f4750fb70b6a016 (patch)
tree9f0071056f7f53129e1eb81a1bca268300d41a05 /src/routes/(app)/register/+page.server.js
parent6d8eb8a609ebb6c1781c463a837bf9e19a6d3d4b (diff)
downloadcoinos-ui-b466b3d39c3b9ec792ef924c7f4750fb70b6a016.tar.gz
coinos-ui-b466b3d39c3b9ec792ef924c7f4750fb70b6a016.zip
prefill register page
Diffstat (limited to 'src/routes/(app)/register/+page.server.js')
-rw-r--r--src/routes/(app)/register/+page.server.js29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/routes/(app)/register/+page.server.js b/src/routes/(app)/register/+page.server.js
index c90d4ee3..f2b49e3f 100644
--- a/src/routes/(app)/register/+page.server.js
+++ b/src/routes/(app)/register/+page.server.js
@@ -1,9 +1,32 @@
+import {
+ NumberDictionary,
+ uniqueNamesGenerator,
+ colors,
+ adjectives,
+ animals
+} from 'unique-names-generator';
import { fail, redirect } from '@sveltejs/kit';
import { fd, post, login } from '$lib/utils';
export const load = async ({ parent }) => {
let { user } = await parent();
if (user) throw redirect(307, `/${user.username}`);
+
+ let username = uniqueNamesGenerator({
+ dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })],
+ length: 2,
+ separator: ''
+ });
+
+ let password = uniqueNamesGenerator({
+ dictionaries: [colors, NumberDictionary.generate({ min: 100, max: 999 })],
+ length: 2,
+ separator: ''
+ });
+
+ let index = Math.floor(Math.random() * 64) + 1;
+
+ return { index, username, password };
};
export const actions = {
@@ -11,8 +34,8 @@ export const actions = {
let ip = request.headers.get('cf-connecting-ip');
let form = await fd(request);
- let { username, password, cipher, salt, pubkey, loginRedirect } = form;
- let user = { username, password, cipher, salt, pubkey };
+ let { profile, username, password, cipher, salt, pubkey, loginRedirect } = form;
+ let user = { profile, username, password, cipher, salt, pubkey };
let error;
if (loginRedirect === 'undefined') loginRedirect = undefined;
@@ -20,7 +43,7 @@ export const actions = {
try {
await post('/register', { user }, { 'cf-connecting-ip': ip });
} catch (e) {
- console.log(e)
+ console.log(e);
if (e.message.includes('taken')) error = e.message;
}