Kajatin
Kajatin
WWasp-lang
Created by Kajatin on 4/29/2023 in #đŸ™‹questions
Cannot log in
I followed the tutorial to set up authentication. The registration works, I can see the user in the database with the hashed password. I'm using username + password authentication. On the login page I'd enter the username and password but when I click login I'm not redirected to my landing page.
app MyProject {
wasp: {
version: "^0.10.2"
},
title: "Title",
auth: {
userEntity: Player,
methods: {
usernameAndPassword: {}
},
onAuthFailedRedirectTo: "/login"
},
client: {
rootComponent: import App from "@client/App",
},
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
component: import Main from "@client/MainPage"
}

route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/auth/SignupPage"
}

route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/auth/LoginPage"
}

entity Player {=psl
id Int @id @default(autoincrement())
username String @unique
password String
psl=}
app MyProject {
wasp: {
version: "^0.10.2"
},
title: "Title",
auth: {
userEntity: Player,
methods: {
usernameAndPassword: {}
},
onAuthFailedRedirectTo: "/login"
},
client: {
rootComponent: import App from "@client/App",
},
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
component: import Main from "@client/MainPage"
}

route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/auth/SignupPage"
}

route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/auth/LoginPage"
}

entity Player {=psl
id Int @id @default(autoincrement())
username String @unique
password String
psl=}
I get a 200 from http://localhost:3001/auth/local/login and my JWT token is there, but then I get a 401 from http://localhost:3001/auth/me :sadboi:
11 replies