(l logging.Logger, client *ent.Client, ctx context.Context)
| 299 | } |
| 300 | |
| 301 | func migrateOAuthClientiOS(l logging.Logger, client *ent.Client, ctx context.Context) error { |
| 302 | if _, err := client.OAuthClient.Query().Where(oauthclient.GUID(OAuthClientiOSGUID)).First(ctx); err == nil { |
| 303 | l.Info("Default OAuth client (GUID=%s) already exists, skip migrating.", OAuthClientiOSGUID) |
| 304 | return nil |
| 305 | } |
| 306 | if _, err := client.OAuthClient.Create(). |
| 307 | SetGUID(OAuthClientiOSGUID). |
| 308 | SetSecret(OAuthClientiOSSecret). |
| 309 | SetName(OAuthClientiOSName). |
| 310 | SetRedirectUris([]string{OAuthClientiOSRedirectURI}). |
| 311 | SetScopes([]string{"profile", "email", "openid", "offline_access", "UserInfo.Write", "UserSecurityInfo.Write", "Workflow.Write", "Files.Write", "Shares.Write", "Finance.Write", "DavAccount.Write"}). |
| 312 | SetProps(&types.OAuthClientProps{Icon: "/static/img/cloudreve_ios.svg", RefreshTokenTTL: 7776000}). |
| 313 | SetIsEnabled(true). |
| 314 | Save(ctx); err != nil { |
| 315 | return fmt.Errorf("failed to create default OAuth client: %w", err) |
| 316 | } |
| 317 | |
| 318 | return nil |
| 319 | } |
| 320 | |
| 321 | func migrateOAuthClientDesktop(l logging.Logger, client *ent.Client, ctx context.Context) error { |
| 322 | if _, err := client.OAuthClient.Query().Where(oauthclient.GUID(OAuthClientDesktopGUID)).First(ctx); err == nil { |
no test coverage detected