mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
using gravatar library instead of our own built-in func
This commit is contained in:
parent
433159e990
commit
110af2a196
4 changed files with 7 additions and 23 deletions
|
@ -1,16 +0,0 @@
|
|||
package gravatar
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// helper function to create a Gravatar Hash
|
||||
// for the given Email address.
|
||||
func Generate(email string) string {
|
||||
email = strings.ToLower(strings.TrimSpace(email))
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(email))
|
||||
return fmt.Sprintf("%x", hash.Sum(nil))
|
||||
}
|
|
@ -6,10 +6,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/ungerik/go-gravatar"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/drone/drone/common"
|
||||
"github.com/drone/drone/common/gravatar"
|
||||
"github.com/drone/drone/common/httputil"
|
||||
"github.com/drone/drone/common/oauth2"
|
||||
)
|
||||
|
@ -87,7 +87,7 @@ func GetLogin(c *gin.Context) {
|
|||
u.Secret = login.Secret
|
||||
u.Name = login.Name
|
||||
u.Email = login.Email
|
||||
u.Gravatar = gravatar.Generate(u.Email)
|
||||
u.Gravatar = gravatar.Hash(u.Email)
|
||||
|
||||
// insert the user into the database
|
||||
if err := store.SetUserNotExists(u); err != nil {
|
||||
|
@ -109,7 +109,7 @@ func GetLogin(c *gin.Context) {
|
|||
u.Secret = login.Secret
|
||||
u.Name = login.Name
|
||||
u.Email = login.Email
|
||||
u.Gravatar = gravatar.Generate(u.Email)
|
||||
u.Gravatar = gravatar.Hash(u.Email)
|
||||
|
||||
if err := store.SetUser(u); err != nil {
|
||||
log.Errorf("cannot update %s. %s", u.Login, err)
|
||||
|
|
|
@ -3,9 +3,9 @@ package server
|
|||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/ungerik/go-gravatar"
|
||||
|
||||
"github.com/drone/drone/common"
|
||||
"github.com/drone/drone/common/gravatar"
|
||||
)
|
||||
|
||||
// GetUserCurr accepts a request to retrieve the
|
||||
|
@ -32,7 +32,7 @@ func PutUserCurr(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
user.Email = in.Email
|
||||
user.Gravatar = gravatar.Generate(in.Email)
|
||||
user.Gravatar = gravatar.Hash(in.Email)
|
||||
err := store.SetUser(user)
|
||||
if err != nil {
|
||||
c.Fail(400, err)
|
||||
|
|
|
@ -3,9 +3,9 @@ package server
|
|||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/ungerik/go-gravatar"
|
||||
|
||||
"github.com/drone/drone/common"
|
||||
"github.com/drone/drone/common/gravatar"
|
||||
)
|
||||
|
||||
// GetUsers accepts a request to retrieve all users
|
||||
|
@ -80,7 +80,7 @@ func PutUser(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
user.Email = in.Email
|
||||
user.Gravatar = gravatar.Generate(user.Email)
|
||||
user.Gravatar = gravatar.Hash(user.Email)
|
||||
|
||||
// an administrator must not be able to
|
||||
// downgrade her own account.
|
||||
|
|
Loading…
Reference in a new issue