export class Account {
constructor(db) {
this.db = db;
}
async create(user) {
const { email, password, password2 } = user;
if (password !== password2) {
throw new Error("Passwords do not match");
}
console.log(user);
let token = await this.db.signup({
NS: "purelygigs",
DB: "purelygigs",
SC: "user",
email,
pass: password,
});
return token;
}
Above is my mojojs model.
I ran this migration to create the user
table first:
DATA="CREATE user;"
curl -k -L -s --compressed POST \
--header "Content-Type: application/json" \
--header "NS: purelygigs" \
--header "DB: purelygigs" \
--user "root:root" \
--data "${DATA}" \
http://localhost:8000/sql
However I am getting this error:
[2022-10-02T17:01:28.021Z] [trace] [1177849-000003] GET "/register"
[2022-10-02T17:01:28.022Z] [trace] [1177849-000003] Routing to "account#register"
[2022-10-02T17:01:28.022Z] [trace] [1177849-000003] Rendering view "account/register"
[2022-10-02T17:01:28.022Z] [trace] [1177849-000003] Rendering layout "layouts/default"
[2022-10-02T17:01:37.619Z] [trace] [1177849-000004] POST "/register"
[2022-10-02T17:01:37.619Z] [trace] [1177849-000004] Routing to "account#create"
[2022-10-02T17:01:37.626Z] [error] [1177849-000004] AuthenticationError: There was a problem with authentication
at Surreal._Surreal_signup (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/index.js:424:23)
at Surreal.<anonymous> (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/index.js:211:111)
at Surreal.f (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/classes/emitter.js:28:18)
at file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/classes/emitter.js:34:22
at Array.forEach (<anonymous>)
at Surreal.emit (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/classes/emitter.js:33:67)
at Socket.<anonymous> (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/index.js:126:29)
at file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/classes/emitter.js:34:22
at Array.forEach (<anonymous>)
at Socket.emit (file:///home/ettinger/src/purelygigs/purelygigs-web/node_modules/surrealdb.js/esm/classes/emitter.js:33:67)
[2022-10-02T17:01:37.627Z] [trace] [1177849-000004] Rendering view "exception.development"
[2022-10-02T17:01:37.627Z] [trace] [1177849-000004] Rendering view "exception"
[2022-10-02T17:01:37.627Z] [trace] [1177849-000004] Rendering view "mojo/debug"