]> source.dussan.org Git - gitea.git/commitdiff
Change drone token name to let users know to use oauth2 (#6912)
authortechknowlogick <techknowlogick@gitea.io>
Sun, 12 May 2019 17:29:07 +0000 (13:29 -0400)
committerGitHub <noreply@github.com>
Sun, 12 May 2019 17:29:07 +0000 (13:29 -0400)
routers/api/v1/user/app.go

index c090a724b7295bb1242a0a0d144463569b850839..8e3b476d36b8e747f002d82bfd83d0f2875b5e84 100644 (file)
@@ -36,6 +36,9 @@ func ListAccessTokens(ctx *context.APIContext) {
 
        apiTokens := make([]*api.AccessToken, len(tokens))
        for i := range tokens {
+               if tokens[i].Name == "drone" {
+                       tokens[i].Name = "drone-legacy-use-oauth2-instead"
+               }
                apiTokens[i] = &api.AccessToken{
                        ID:             tokens[i].ID,
                        Name:           tokens[i].Name,
@@ -76,14 +79,18 @@ func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption
                UID:  ctx.User.ID,
                Name: form.Name,
        }
+       if t.Name == "drone" {
+               t.Name = "drone-legacy-use-oauth2-instead"
+       }
        if err := models.NewAccessToken(t); err != nil {
                ctx.Error(500, "NewAccessToken", err)
                return
        }
        ctx.JSON(201, &api.AccessToken{
-               Name:  t.Name,
-               Token: t.Token,
-               ID:    t.ID,
+               Name:           t.Name,
+               Token:          t.Token,
+               ID:             t.ID,
+               TokenLastEight: t.TokenLastEight,
        })
 }