File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -235,13 +235,18 @@ func CreateSource(ctx context.Context, source *Source) error {
235235 err = registerableSource .RegisterSource ()
236236 if err != nil {
237237 // remove the AuthSource in case of errors while registering configuration
238- if _ , err := db . GetEngine (ctx ). ID ( source .ID ). Delete ( new ( Source ) ); err != nil {
238+ if err := DeleteSource (ctx , source .ID ); err != nil {
239239 log .Error ("CreateSource: Error while wrapOpenIDConnectInitializeError: %v" , err )
240240 }
241241 }
242242 return err
243243}
244244
245+ func DeleteSource (ctx context.Context , id int64 ) error {
246+ _ , err := db .GetEngine (ctx ).ID (id ).Delete (new (Source ))
247+ return err
248+ }
249+
245250type FindSourcesOptions struct {
246251 db.ListOptions
247252 IsActive optional.Option [bool ]
Original file line number Diff line number Diff line change 88 "fmt"
99 "net/http"
1010 "net/url"
11+ "strconv"
1112
1213 auth_model "code.gitea.io/gitea/models/auth"
1314 api "code.gitea.io/gitea/modules/structs"
@@ -74,6 +75,20 @@ func EditOauthAuth(ctx *context.APIContext) {
7475
7576// DeleteOauthAuth api for deleting a authentication method
7677func DeleteOauthAuth (ctx * context.APIContext ) {
78+ oauthIdString := ctx .PathParam ("id" )
79+ oauthID , oauthIdErr := strconv .Atoi (oauthIdString )
80+ if oauthIdErr != nil {
81+ ctx .APIErrorInternal (oauthIdErr )
82+ }
83+
84+ err := auth_model .DeleteSource (ctx , int64 (oauthID ))
85+
86+ if err != nil {
87+ ctx .APIErrorInternal (err )
88+ return
89+ }
90+
91+ ctx .Status (http .StatusOK )
7792}
7893
7994// // SearchOauthAuth API for getting information of the configured authentication methods according the filter conditions
Original file line number Diff line number Diff line change @@ -1650,8 +1650,11 @@ func Routes() *web.Router {
16501650
16511651 m .Group ("/admin" , func () {
16521652 m .Group ("/identity-auth" , func () {
1653- m .Get ("" , admin .SearchOauthAuth )
1654- m .Post ("/new" , admin .CreateOauthAuth )
1653+ m .Group ("oauth" , func () {
1654+ m .Get ("" , admin .SearchOauthAuth )
1655+ m .Delete ("/{id}" , admin .DeleteOauthAuth )
1656+ m .Post ("/new" , admin .CreateOauthAuth )
1657+ })
16551658 })
16561659
16571660 m .Group ("/cron" , func () {
You can’t perform that action at this time.
0 commit comments