Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
GuzhavinAleksey committed May 18, 2023
1 parent ff285cb commit ab4eb02
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
12 changes: 8 additions & 4 deletions app/Http/Controllers/AuthController.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func UsersRegistration(c *gin.Context) {
user := Model.UserModel{
Name: input.Name,
Email: input.Email,
Password: input.Password}
Password: input.Password,
}

//Gorm_SQL
config.DB.Save(&user)
Expand Down Expand Up @@ -114,7 +115,8 @@ func UsersLogin(c *gin.Context) {
c.IndentedJSON(http.StatusCreated, gin.H{
"message": "User signed in",
"user": model.Name,
"id": model.ID})
"id": model.ID,
})
}

}
Expand Down Expand Up @@ -226,11 +228,13 @@ func ViewUserSession(c *gin.Context) {
if sessionID == nil {
c.IndentedJSON(http.StatusOK, gin.H{
"userid_session_id": "no_auth",
"userid_session": "no_auth"})
"userid_session": "no_auth",
})
} else {
c.IndentedJSON(http.StatusOK, gin.H{
"userid_session_id": sessionID,
"userid_session": "auth"})
"userid_session": "auth",
})
}

}
Expand Down
24 changes: 16 additions & 8 deletions app/Http/Controllers/CasbinRoleController.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ func AddPostCasbinRole(c *gin.Context) {
e.AddPolicy(
input.RoleName,
input.Path,
input.Method)
input.Method,
)

// Create role
role := Model.CasbinRoleModel{
RoleName: input.RoleName,
Path: input.Path,
Method: input.Method}
Method: input.Method,
}

//Gorm_SQL
config.DB.Save(&role)
Expand Down Expand Up @@ -87,7 +89,8 @@ func ViewCasbinRole(c *gin.Context) {
c.HTML(http.StatusOK, "admin_views_casbin_role.html", gin.H{
"session_id": sessionID,
"session_name": sessionName,
"list": model})
"list": model,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand Down Expand Up @@ -118,7 +121,8 @@ func AddCasbinRole(c *gin.Context) {
c.HTML(http.StatusOK, "admin_views_casbin_role_add.html", gin.H{
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand All @@ -141,7 +145,8 @@ func DeleteCasbinRole(c *gin.Context) {
e.RemovePolicy(
model.RoleName,
model.Path,
model.Method)
model.Method,
)

config.DB.Delete(&model)

Expand Down Expand Up @@ -169,7 +174,8 @@ func ApiViewCasbinRole(c *gin.Context) {
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName,
"list": model})
"list": model,
})

}

Expand All @@ -187,7 +193,8 @@ func ApiAddCasbinRole(c *gin.Context) {
c.IndentedJSON(http.StatusOK, gin.H{
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})

}

Expand All @@ -206,7 +213,8 @@ func ApiDeleteCasbinRole(c *gin.Context) {
e.RemovePolicy(
model.RoleName,
model.Path,
model.Method)
model.Method,
)

config.DB.Delete(&model)

Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/HomeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func ViewHome(c *gin.Context) {
//HTML template
c.HTML(http.StatusOK, "admin_views_home.html", gin.H{
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand All @@ -60,6 +61,7 @@ func ApiViewHome(c *gin.Context) {
c.IndentedJSON(http.StatusOK, gin.H{
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})

}
9 changes: 6 additions & 3 deletions app/Http/Controllers/ResPassController.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func PostForgotPassword(c *gin.Context) {
url_res := Model.ResPassUserModel{
Email: input.Email,
Url_full: config.EnvFunc("WWWROOT") + "/login/pass/" + rand_urls,
Url: rand_urls}
Url: rand_urls,
}

config.DB.Save(&url_res)

Expand Down Expand Up @@ -129,7 +130,8 @@ func ViewRes_passListPrev(c *gin.Context) { // Get model if exist
//HTML template
c.HTML(http.StatusOK, "admin_auth_forgot_password_new.html", gin.H{
"csrf": csrf.GetToken(c),
"url": model.Url})
"url": model.Url,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand Down Expand Up @@ -212,5 +214,6 @@ func ApiViewRes_passListPrev(c *gin.Context) {

c.IndentedJSON(http.StatusOK, gin.H{
"csrf": csrf.GetToken(c),
"url": model.Url})
"url": model.Url,
})
}
12 changes: 8 additions & 4 deletions app/Http/Controllers/UserController.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ func ViewUsersList(c *gin.Context) {
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName,
"list": model})
"list": model,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand Down Expand Up @@ -242,7 +243,8 @@ func ViewAddUsers(c *gin.Context) { // Get model if exist
c.HTML(http.StatusOK, "admin_views_users_add.html", gin.H{
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand Down Expand Up @@ -271,7 +273,8 @@ func ApiViewUsersList(c *gin.Context) {
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName,
"list": model})
"list": model,
})

}

Expand All @@ -289,7 +292,8 @@ func ApiViewAddUsers(c *gin.Context) { // Get model if exist
c.IndentedJSON(http.StatusOK, gin.H{
"csrf": csrf.GetToken(c),
"session_id": sessionID,
"session_name": sessionName})
"session_name": sessionName,
})

}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/WelcomeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func GetWelcome(c *gin.Context) {
//HTML template
c.HTML(http.StatusOK, "public_welcome.html", gin.H{
"title": "Larago",
"session_id": sessionID})
"session_id": sessionID,
})
default:
//VUE template
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Larago"})
Expand Down

0 comments on commit ab4eb02

Please sign in to comment.