1
1
/*
2
2
* This file is part of QLBase (https://github.com/nthnn/QLBase).
3
3
* Copyright 2024 - Nathanne Isip
4
- *
4
+ *
5
5
* Permission is hereby granted, free of charge,
6
6
* to any person obtaining a copy of this software
7
7
* and associated documentation files (the “Software”),
11
11
* sell copies of the Software, and to permit persons to
12
12
* whom the Software is furnished to do so, subject to
13
13
* the following conditions:
14
- *
14
+ *
15
15
* The above copyright notice and this permission notice
16
16
* shall be included in all copies or substantial portions
17
17
* of the Software.
18
- *
18
+ *
19
19
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF
20
20
* ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
21
21
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
@@ -34,6 +34,7 @@ import (
34
34
"os"
35
35
"strconv"
36
36
37
+ "github.com/google/uuid"
37
38
"github.com/nthnn/QLBase/auth/proc"
38
39
)
39
40
@@ -608,12 +609,21 @@ func loginUserWithUsername(apiKey string, args []string) func(*sql.DB) {
608
609
count += 1
609
610
}
610
611
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
615
624
}
616
625
626
+ proc .ShowResult ("\" " + uuid + "\" " )
617
627
query .Close ()
618
628
}
619
629
}
0 commit comments