i fucking hate git
Cette révision appartient à :
Parent
c500c90a57
révision
74038c9137
2 fichiers modifiés avec 15 ajouts et 31 suppressions
|
@ -133,6 +133,10 @@ func ApiUploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
db.ORM.Create(&torrent)
|
db.ORM.Create(&torrent)
|
||||||
|
if err != nil {
|
||||||
|
util.SendError(w, err, 500)
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Printf("%+v\n", torrent)
|
fmt.Printf("%+v\n", torrent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +147,6 @@ func ApiUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
if contentType == "application/json" {
|
if contentType == "application/json" {
|
||||||
token := r.Header.Get("Authorization")
|
token := r.Header.Get("Authorization")
|
||||||
|
@ -180,27 +183,13 @@ func ApiUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), code)
|
http.Error(w, err.Error(), code)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%+v\n", torrent)
|
|
||||||
update.UpdateTorrent(&torrent)
|
update.UpdateTorrent(&torrent)
|
||||||
|
|
||||||
db.ORM.Save(&torrent)
|
db.ORM.Save(&torrent)
|
||||||
|
if err != nil {
|
||||||
|
util.SendError(w, err, 500)
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Printf("%+v\n", torrent)
|
fmt.Printf("%+v\n", torrent)
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
torrent := model.Torrents{
|
|
||||||
Name: b.Name,
|
|
||||||
Category: category,
|
|
||||||
Sub_Category: sub_category,
|
|
||||||
Status: 1,
|
|
||||||
Hash: b.Hash,
|
|
||||||
Date: time.Now(),
|
|
||||||
Filesize: 0,
|
|
||||||
Description: string(b.Description)}
|
|
||||||
err = db.ORM.Create(&torrent).Error
|
|
||||||
if err != nil {
|
|
||||||
util.SendError(w, err, 500)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf("%+v\n", torrent)
|
|
||||||
>>>>>>> 7ea85cf3140d8f9c32c3637b7e9f73a0e744aee8
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,16 +62,11 @@ func CreateUserFromForm(registrationForm formStruct.RegistrationForm) (model.Use
|
||||||
var user model.User
|
var user model.User
|
||||||
log.Debugf("registrationForm %+v\n", registrationForm)
|
log.Debugf("registrationForm %+v\n", registrationForm)
|
||||||
modelHelper.AssignValue(&user, ®istrationForm)
|
modelHelper.AssignValue(&user, ®istrationForm)
|
||||||
<<<<<<< HEAD
|
|
||||||
user.Md5 = crypto.GenerateMD5Hash(user.Email) // Gravatar
|
|
||||||
=======
|
|
||||||
|
|
||||||
if user.Email == "" {
|
if user.Email == "" {
|
||||||
user.Md5 = ""
|
user.Md5 = ""
|
||||||
} else {
|
} else {
|
||||||
user.Md5 = crypto.GenerateMD5Hash(user.Email)
|
user.Md5 = crypto.GenerateMD5Hash(user.Email)
|
||||||
}
|
}
|
||||||
>>>>>>> 7ea85cf3140d8f9c32c3637b7e9f73a0e744aee8
|
|
||||||
token, err := crypto.GenerateRandomToken32()
|
token, err := crypto.GenerateRandomToken32()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return user, errors.New("Token not generated.")
|
return user, errors.New("Token not generated.")
|
||||||
|
@ -175,7 +170,7 @@ func UpdateUser(w http.ResponseWriter, form *formStruct.UserForm, currentUser *m
|
||||||
return user, http.StatusNotFound, errors.New("User is not found.")
|
return user, http.StatusNotFound, errors.New("User is not found.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form.Password != "") {
|
if form.Password != "" {
|
||||||
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(form.CurrentPassword))
|
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(form.CurrentPassword))
|
||||||
if err != nil && !userPermission.HasAdmin(currentUser) {
|
if err != nil && !userPermission.HasAdmin(currentUser) {
|
||||||
log.Error("Password Incorrect.")
|
log.Error("Password Incorrect.")
|
||||||
|
@ -195,14 +190,14 @@ func UpdateUser(w http.ResponseWriter, form *formStruct.UserForm, currentUser *m
|
||||||
form.Status = user.Status
|
form.Status = user.Status
|
||||||
form.Username = user.Username
|
form.Username = user.Username
|
||||||
}
|
}
|
||||||
log.Debugf("form %+v\n", form)
|
log.Debugf("form %+v\n", form)
|
||||||
modelHelper.AssignValue(&user, form)
|
modelHelper.AssignValue(&user, form)
|
||||||
|
|
||||||
status, err := UpdateUserCore(&user)
|
status, err := UpdateUserCore(&user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return user, status, err
|
return user, status, err
|
||||||
}
|
}
|
||||||
if (userPermission.CurrentUserIdentical(currentUser, user.Id)) {
|
if userPermission.CurrentUserIdentical(currentUser, user.Id) {
|
||||||
status, err = SetCookie(w, user.Token)
|
status, err = SetCookie(w, user.Token)
|
||||||
}
|
}
|
||||||
return user, status, err
|
return user, status, err
|
||||||
|
@ -217,8 +212,8 @@ func DeleteUser(w http.ResponseWriter, currentUser *model.User, id string) (int,
|
||||||
if db.ORM.Delete(&user).Error != nil {
|
if db.ORM.Delete(&user).Error != nil {
|
||||||
return http.StatusInternalServerError, errors.New("User is not deleted.")
|
return http.StatusInternalServerError, errors.New("User is not deleted.")
|
||||||
}
|
}
|
||||||
if (userPermission.CurrentUserIdentical(currentUser, user.Id)) {
|
if userPermission.CurrentUserIdentical(currentUser, user.Id) {
|
||||||
return ClearCookie(w)
|
return ClearCookie(w)
|
||||||
}
|
}
|
||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
Référencer dans un nouveau ticket