完善登录与鉴权机制
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"platform/pkg/orm"
|
||||
"platform/web/models"
|
||||
q "platform/web/queries"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -14,41 +16,59 @@ func main() {
|
||||
logs.Init()
|
||||
orm.Init()
|
||||
|
||||
q.User.Select(
|
||||
q.User.Phone,
|
||||
).Create(&models.User{
|
||||
Phone: "12312341234",
|
||||
})
|
||||
q.User.
|
||||
Select(
|
||||
q.User.Phone).
|
||||
Create(&models.User{
|
||||
Phone: "12312341234"})
|
||||
|
||||
q.Proxy.Select(
|
||||
q.Proxy.Version,
|
||||
q.Proxy.Name,
|
||||
q.Proxy.Host,
|
||||
q.Proxy.Type,
|
||||
).Create(&models.Proxy{
|
||||
Version: 1,
|
||||
Name: "7a17e8b4-cdc3-4500-bf16-4a665991a7f6",
|
||||
Host: "110.40.82.248",
|
||||
Type: 1,
|
||||
})
|
||||
q.Proxy.
|
||||
Select(
|
||||
q.Proxy.Version,
|
||||
q.Proxy.Name,
|
||||
q.Proxy.Host,
|
||||
q.Proxy.Type).
|
||||
Create(&models.Proxy{
|
||||
Version: 1,
|
||||
Name: "7a17e8b4-cdc3-4500-bf16-4a665991a7f6",
|
||||
Host: "110.40.82.248",
|
||||
Type: 1})
|
||||
|
||||
q.Node.Select(
|
||||
q.Node.Version,
|
||||
q.Node.Name,
|
||||
q.Node.Host,
|
||||
q.Node.Isp,
|
||||
q.Node.Prov,
|
||||
q.Node.City,
|
||||
q.Node.Status,
|
||||
).Create(&models.Node{
|
||||
Version: 1,
|
||||
Name: "test-node",
|
||||
Host: "123",
|
||||
Isp: "test-isp",
|
||||
Prov: "test-prov",
|
||||
City: "test-city",
|
||||
Status: 1,
|
||||
})
|
||||
q.Node.
|
||||
Select(
|
||||
q.Node.Version,
|
||||
q.Node.Name,
|
||||
q.Node.Host,
|
||||
q.Node.Isp,
|
||||
q.Node.Prov,
|
||||
q.Node.City,
|
||||
q.Node.Status).
|
||||
Create(&models.Node{
|
||||
Version: 1,
|
||||
Name: "test-node",
|
||||
Host: "123",
|
||||
Isp: "test-isp",
|
||||
Prov: "test-prov",
|
||||
City: "test-city",
|
||||
Status: 1})
|
||||
|
||||
var secret, _ = bcrypt.GenerateFromPassword([]byte("test"), bcrypt.DefaultCost)
|
||||
q.Client.
|
||||
Select(
|
||||
q.Client.ClientID,
|
||||
q.Client.ClientSecret,
|
||||
q.Client.GrantClient,
|
||||
q.Client.GrantRefresh,
|
||||
q.Client.Spec,
|
||||
q.Client.Name).
|
||||
Create(&models.Client{
|
||||
ClientID: "test",
|
||||
ClientSecret: string(secret),
|
||||
GrantClient: true,
|
||||
GrantRefresh: true,
|
||||
Spec: 0,
|
||||
Name: "默认客户端",
|
||||
})
|
||||
|
||||
slog.Info("✔ Data inserted successfully")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user