Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cfccc2722
|
||
|
|
801a314421
|
||
|
|
9565259dc1
|
||
|
|
f05a513926
|
||
|
|
39ecf052a0
|
||
|
|
2b5cb3a093
|
||
|
|
c2cde15189
|
||
|
|
b8e8621e0d
|
||
|
|
0bf24d929c
|
||
|
|
dcbc2609c4
|
@@ -25,7 +25,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Creating version"
|
echo "Creating version"
|
||||||
|
|
||||||
VERSION="0.2.3"
|
VERSION="0.2.1"
|
||||||
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
|
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
|
||||||
BRANCH_REF="${{ gitea.ref }}"
|
BRANCH_REF="${{ gitea.ref }}"
|
||||||
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UserLoginHistory struct {
|
|
||||||
Id uuid.UUID `json:"id"`
|
|
||||||
LoginTime time.Time `json:"login_time"`
|
|
||||||
UserId uuid.UUID `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ServiceUserLoginHistory struct {
|
|
||||||
Id uuid.UUID `json:"id"`
|
|
||||||
LoginTime time.Time `json:"login_time"`
|
|
||||||
ServiceUserId uuid.UUID `json:"service_user_id"`
|
|
||||||
}
|
|
||||||
+8
-10
@@ -7,14 +7,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id uuid.UUID `json:"id"`
|
Id uuid.UUID `json:"id"`
|
||||||
PhoneNumber string `json:"phone_number"`
|
PhoneNumber string `json:"phone_number"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
// Firstname is a pointer
|
Firstname *string `json:"first_name,omitempty"`
|
||||||
Firstname *string `json:"first_name,omitempty"`
|
Lastname *string `json:"last_name,omitempty"`
|
||||||
// Lastname is a pointer
|
Created time.Time `json:"created"`
|
||||||
Lastname *string `json:"last_name,omitempty"`
|
LastLogin *time.Time `json:"last_login,omitempty"`
|
||||||
Created time.Time `json:"created"`
|
|
||||||
LastLogin *time.Time `json:"last_login,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-29
@@ -1,41 +1,26 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UserProfile struct {
|
type UserProfile struct {
|
||||||
UserId uuid.UUID `json:"user_id"`
|
Usr *User `json:"user"`
|
||||||
PhoneNumber string `json:"phone_number"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Firstname *string `json:"firstname,omitempty"`
|
|
||||||
Lastname *string `json:"lastname,omitempty"`
|
|
||||||
Created time.Time `json:"created"`
|
|
||||||
LastLogin *time.Time `json:"last_login,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitUserProfile(usr *User) (usrProfile *UserProfile, err error) {
|
func InitUserProfile(usr *User) (usrProfile *UserProfile, done bool) {
|
||||||
if usr == nil {
|
if usr == nil {
|
||||||
return nil, fmt.Errorf("User is empty")
|
return nil, false
|
||||||
} else {
|
} else {
|
||||||
usrProfile = new(UserProfile)
|
usrProfile = new(UserProfile)
|
||||||
usrProfile.UserId = usr.Id
|
if len(usr.Password) > 0 {
|
||||||
usrProfile.PhoneNumber = usr.PhoneNumber
|
var newUsr User
|
||||||
usrProfile.Username = usr.Username
|
newUsr = *usr
|
||||||
if usr.Firstname != nil {
|
newUsr.Password = ""
|
||||||
usrProfile.Firstname = usr.Firstname
|
usrProfile.Usr = &newUsr
|
||||||
}
|
|
||||||
if usr.Lastname != nil {
|
|
||||||
usrProfile.Lastname = usr.Lastname
|
|
||||||
}
|
|
||||||
usrProfile.Created = usr.Created
|
|
||||||
if usr.LastLogin != nil {
|
|
||||||
usrProfile.LastLogin = usr.LastLogin
|
|
||||||
}
|
|
||||||
|
|
||||||
return usrProfile, nil
|
return usrProfile, true
|
||||||
|
} else {
|
||||||
|
usrProfile.Usr = usr
|
||||||
|
return usrProfile, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
func TestInitUserProfile(t *testing.T) {
|
func TestInitUserProfile(t *testing.T) {
|
||||||
usr := User{Username: "Bob", PhoneNumber: "+12224572351", Password: "TheNight!"}
|
usr := User{Username: "Bob", PhoneNumber: "+12224572351", Password: "TheNight!"}
|
||||||
|
|
||||||
profile, err := InitUserProfile(&usr)
|
profile, done := InitUserProfile(&usr)
|
||||||
|
|
||||||
assert.NoError(t, err, "Error %v", err)
|
assert.Equal(t, done, true, "Error")
|
||||||
assert.NotEmpty(t, profile, "UserProfile is empty")
|
assert.NotEmpty(t, profile, "UserProfile is empty")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user