File size: 767 Bytes
131eba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package auth

import (
	"github.com/gin-gonic/gin"
	"pweb-api.abdanhafidz.com/controller"
	"pweb-api.abdanhafidz.com/models"
	"pweb-api.abdanhafidz.com/services"
)

func ChangePassword(c *gin.Context) {
	authentication := services.AuthenticationService{}
	changePasswordController := controller.Controller[models.ChangePasswordRequest, models.Account, models.AuthenticatedUser]{
		Service: &authentication.Service,
	}
	changePasswordController.HeaderParse(c, func() {
		changePasswordController.Service.Constructor.Id = uint(changePasswordController.AccountData.UserID)
	})
	changePasswordController.RequestJSON(c, func() {
		authentication.Update(changePasswordController.Request.OldPassword, changePasswordController.Request.NewPassword)
	})
}