File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
src/Our.Umbraco.AuthU/Data/Migrations/UmbracoDbOAuthClientStore Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ using Our . Umbraco . AuthU . Models ;
2+ using Umbraco . Core . Migrations ;
3+
4+ namespace Our . Umbraco . AuthU . Data . Migrations . UmbracoDbOAuthClientStore
5+ {
6+ /// <summary>
7+ /// Simple migration to create the OAuthClient Table
8+ /// </summary>
9+ internal class CreateAuthClientStoreTable : MigrationBase
10+ {
11+ public CreateAuthClientStoreTable ( IMigrationContext context )
12+ : base ( context )
13+ { }
14+
15+ public override void Migrate ( )
16+ {
17+ if ( ! TableExists ( "OAuthClient" ) )
18+ Create . Table < OAuthClient > ( ) . Do ( ) ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ using Our . Umbraco . AuthU . Models ;
2+ using Umbraco . Core . Migrations ;
3+
4+ namespace Our . Umbraco . AuthU . Data . Migrations . UmbracoDbOAuthClientStore
5+ {
6+ /// <summary>
7+ /// Simple migration to add a demo client to the OAuthClient Table
8+ /// </summary>
9+ internal class CreateDemoClient : MigrationBase
10+ {
11+ public CreateDemoClient ( IMigrationContext context ) : base ( context )
12+ { }
13+
14+ public override void Migrate ( )
15+ {
16+ var existing = Database . SingleOrDefault < OAuthClient > ( $ "SELECT 1 FROM [OAuthClient] WHERE [ClientId] = @0", "DemoClient" ) ;
17+ if ( existing == null )
18+ {
19+ Database . Save ( new OAuthClient
20+ {
21+ ClientId = "DemoClient" ,
22+ Name = "Demo Client" ,
23+ Secret = "demo" ,
24+ SecurityLevel = SecurityLevel . Insecure ,
25+ RefreshTokenLifeTime = 14400 ,
26+ AllowedOrigin = "*"
27+ } ) ;
28+ }
29+ }
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments