This commit is contained in:
2024-07-02 15:34:44 +05:30
parent 8f2c51ac5c
commit 6258cf9e02

View File

@@ -36,4 +36,22 @@ fn (mut app App) service_add_user(username string, email string, password string
if insert_error != '' {
return error(insert_error)
}
}
fn (mut app App) service_login(username string, password string) !Auth {
mut db := databases.create_db_connection()!
defer {
db.close() or { panic(err) }
}
results := sql db {
select from Auth where username == username && password == password
}!
if results.len == 0 {
return error('User not found')
}
return results[0]
}