This commit is contained in:
2024-07-04 04:31:15 +05:30
parent be276acef4
commit c4b725b4a6
2 changed files with 19 additions and 3 deletions

View File

@@ -23,7 +23,6 @@ pub fn (mut app App) post_signup(username string, email string, password string)
@['/controller/signup'] @['/controller/signup']
pub fn (mut app App) controller_signup() vweb.Result{ pub fn (mut app App) controller_signup() vweb.Result{
username := app.query["username"] username := app.query["username"]
print(username)
email := app.query["email"] email := app.query["email"]
password := app.query["password"] password := app.query["password"]
app.service_add_user(username, email, password) or { app.service_add_user(username, email, password) or {
@@ -54,3 +53,18 @@ pub fn (mut app App) post_login(username string, password string) vweb.Result{
return app.json(user) return app.json(user)
} }
@['/controller/login']
pub fn (mut app App) controller_login() vweb.Result{
username := app.query["username"]
password := app.query["password"]
user := app.service_login(username, password) or {
mut noti := Noti{
status: "failure",
message: err.str()
}
return app.json(noti)
}
return app.json(user)
}

View File

@@ -10,8 +10,10 @@
<h1 class="text-3xl mb-6 font-bold text-center text-blue-500">Welcome Back!</h1> <h1 class="text-3xl mb-6 font-bold text-center text-blue-500">Welcome Back!</h1>
<form action="/login" method="post"> <form action="/login" method="post">
<div class="mb-4"> <div class="mb-4">
<label for="email" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Email:</label> <!-- <label for="email" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Email:</label>
<input type="email" id="email" name="email" placeholder="Enter email address" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/> <input type="email" id="email" name="email" placeholder="Enter email address" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/> -->
<label for="text" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Username:</label>
<input type="text" id="email" name="username" placeholder="Enter username" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
</div> </div>
<div class="mb-4"> <div class="mb-4">
<label for="password" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Password:</label> <label for="password" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Password:</label>