Skip to content

Commit aa163f5

Browse files
committed
Updated callback result for authentication login action.
1 parent 9234d22 commit aa163f5

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

backend/auth/callback.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of QLBase (https://github.com/nthnn/QLBase).
33
* Copyright 2024 - Nathanne Isip
4-
*
4+
*
55
* Permission is hereby granted, free of charge,
66
* to any person obtaining a copy of this software
77
* and associated documentation files (the “Software”),
@@ -11,11 +11,11 @@
1111
* sell copies of the Software, and to permit persons to
1212
* whom the Software is furnished to do so, subject to
1313
* the following conditions:
14-
*
14+
*
1515
* The above copyright notice and this permission notice
1616
* shall be included in all copies or substantial portions
1717
* of the Software.
18-
*
18+
*
1919
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF
2020
* ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
2121
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
@@ -34,6 +34,7 @@ import (
3434
"os"
3535
"strconv"
3636

37+
"github.com/google/uuid"
3738
"github.com/nthnn/QLBase/auth/proc"
3839
)
3940

@@ -608,12 +609,21 @@ func loginUserWithUsername(apiKey string, args []string) func(*sql.DB) {
608609
count += 1
609610
}
610611

611-
if count == 1 {
612-
proc.ShowResult("\"1\"")
613-
} else {
614-
proc.ShowResult("\"0\"")
612+
if count != 1 {
613+
proc.ShowResult("\"error\"")
614+
}
615+
616+
uuid := uuid.New().String()
617+
query, err = d.Query("INSERT INTO " + apiKey +
618+
"_account_session (username, uuid) VALUES(\"" +
619+
username + "\", \"" + uuid + "\")")
620+
621+
if err != nil {
622+
proc.ShowFailedResponse("Internal error occured.")
623+
return
615624
}
616625

626+
proc.ShowResult("\"" + uuid + "\"")
617627
query.Close()
618628
}
619629
}

0 commit comments

Comments
 (0)