Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

i fucking hate git

Cette révision appartient à :
ayame-git 2017-05-10 00:21:15 +03:00
Parent ab330e77c7
révision 4bd79520a9
2 fichiers modifiés avec 15 ajouts et 31 suppressions

Voir le fichier

@ -133,6 +133,10 @@ func ApiUploadHandler(w http.ResponseWriter, r *http.Request) {
}
db.ORM.Create(&torrent)
if err != nil {
util.SendError(w, err, 500)
return
}
fmt.Printf("%+v\n", torrent)
}
}
@ -143,7 +147,6 @@ func ApiUpdateHandler(w http.ResponseWriter, r *http.Request) {
return
}
<<<<<<< HEAD
contentType := r.Header.Get("Content-Type")
if contentType == "application/json" {
token := r.Header.Get("Authorization")
@ -180,27 +183,13 @@ func ApiUpdateHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), code)
return
}
fmt.Printf("%+v\n", torrent)
update.UpdateTorrent(&torrent)
db.ORM.Save(&torrent)
if err != nil {
util.SendError(w, err, 500)
return
}
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
}

Voir le fichier

@ -62,16 +62,11 @@ func CreateUserFromForm(registrationForm formStruct.RegistrationForm) (model.Use
var user model.User
log.Debugf("registrationForm %+v\n", registrationForm)
modelHelper.AssignValue(&user, &registrationForm)
<<<<<<< HEAD
user.Md5 = crypto.GenerateMD5Hash(user.Email) // Gravatar
=======
if user.Email == "" {
user.Md5 = ""
} else {
user.Md5 = crypto.GenerateMD5Hash(user.Email)
}
>>>>>>> 7ea85cf3140d8f9c32c3637b7e9f73a0e744aee8
token, err := crypto.GenerateRandomToken32()
if err != nil {
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.")
}
if (form.Password != "") {
if form.Password != "" {
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(form.CurrentPassword))
if err != nil && !userPermission.HasAdmin(currentUser) {
log.Error("Password Incorrect.")
@ -195,14 +190,14 @@ func UpdateUser(w http.ResponseWriter, form *formStruct.UserForm, currentUser *m
form.Status = user.Status
form.Username = user.Username
}
log.Debugf("form %+v\n", form)
modelHelper.AssignValue(&user, form)
log.Debugf("form %+v\n", form)
modelHelper.AssignValue(&user, form)
status, err := UpdateUserCore(&user)
if err != nil {
return user, status, err
}
if (userPermission.CurrentUserIdentical(currentUser, user.Id)) {
if userPermission.CurrentUserIdentical(currentUser, user.Id) {
status, err = SetCookie(w, user.Token)
}
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 {
return http.StatusInternalServerError, errors.New("User is not deleted.")
}
if (userPermission.CurrentUserIdentical(currentUser, user.Id)) {
return ClearCookie(w)
if userPermission.CurrentUserIdentical(currentUser, user.Id) {
return ClearCookie(w)
}
return http.StatusOK, nil
}