separate frontend repository
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"s-ui/config"
|
||||
"s-ui/database"
|
||||
"s-ui/service"
|
||||
)
|
||||
|
||||
func resetAdmin() {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
userService := service.UserService{}
|
||||
err = userService.UpdateFirstUser("admin", "admin")
|
||||
if err != nil {
|
||||
fmt.Println("reset admin credentials failed:", err)
|
||||
} else {
|
||||
fmt.Println("reset admin credentials success")
|
||||
}
|
||||
}
|
||||
|
||||
func updateAdmin(username string, password string) {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
if username != "" || password != "" {
|
||||
userService := service.UserService{}
|
||||
err := userService.UpdateFirstUser(username, password)
|
||||
if err != nil {
|
||||
fmt.Println("reset admin credentials failed:", err)
|
||||
} else {
|
||||
fmt.Println("reset admin credentials success")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func showAdmin() {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
userService := service.UserService{}
|
||||
userModel, err := userService.GetFirstUser()
|
||||
if err != nil {
|
||||
fmt.Println("get current user info failed,error info:", err)
|
||||
}
|
||||
username := userModel.Username
|
||||
userpasswd := userModel.Password
|
||||
if (username == "") || (userpasswd == "") {
|
||||
fmt.Println("current username or password is empty")
|
||||
}
|
||||
fmt.Println("First admin credentials:")
|
||||
fmt.Println("\tUsername:\t", username)
|
||||
fmt.Println("\tPassword:\t", userpasswd)
|
||||
}
|
||||
Reference in New Issue
Block a user