@@ -29,14 +29,14 @@ public IdentityManagerMetadata GetMetadata()
2929 {
3030 var createprops = new List < PropertyMetadata > ( )
3131 {
32- PropertyMetadata . FromProperty < InMemoryUser > ( x => x . Username , name : Constants . ClaimTypes . Username , required : true ) ,
32+ PropertyMetadata . FromProperty < InMemoryUser > ( x => x . Username , name : IdentityManagerConstants . ClaimTypes . Username , required : true ) ,
3333 } ;
3434
3535 var updateprops = new List < PropertyMetadata > ( ) ;
3636 updateprops . AddRange ( new PropertyMetadata [ ] {
37- PropertyMetadata . FromProperty < InMemoryUser > ( x => x . Username , name : Constants . ClaimTypes . Username , required : true ) ,
38- PropertyMetadata . FromPropertyName < InMemoryUser > ( "Password" , name : Constants . ClaimTypes . Password , required : true ) ,
39- PropertyMetadata . FromFunctions < InMemoryUser , string > ( Constants . ClaimTypes . Name , u => GetName ( u ) , SetName , displayName : "DisplayName" , required : true ) ,
37+ PropertyMetadata . FromProperty < InMemoryUser > ( x => x . Username , name : IdentityManagerConstants . ClaimTypes . Username , required : true ) ,
38+ PropertyMetadata . FromPropertyName < InMemoryUser > ( "Password" , name : IdentityManagerConstants . ClaimTypes . Password , required : true ) ,
39+ PropertyMetadata . FromFunctions < InMemoryUser , string > ( IdentityManagerConstants . ClaimTypes . Name , u => GetName ( u ) , SetName , displayName : "DisplayName" , required : true ) ,
4040 } ) ;
4141 updateprops . AddRange ( PropertyMetadata . FromType < InMemoryUser > ( ) ) ;
4242 updateprops . AddRange ( new PropertyMetadata [ ] {
@@ -76,7 +76,7 @@ public IdentityManagerMetadata GetMetadata()
7676 } ,
7777 RoleMetadata = new RoleMetadata
7878 {
79- RoleClaimType = Constants . ClaimTypes . Role ,
79+ RoleClaimType = IdentityManagerConstants . ClaimTypes . Role ,
8080 SupportsCreate = true ,
8181 SupportsDelete = true ,
8282 CreateProperties = roleCreateProps ,
@@ -91,15 +91,15 @@ private string GetName(InMemoryUser user)
9191 {
9292 if ( user == null ) throw new ArgumentNullException ( ) ;
9393
94- return user . Claims . GetValue ( Constants . ClaimTypes . Name ) ;
94+ return user . Claims . GetValue ( IdentityManagerConstants . ClaimTypes . Name ) ;
9595 }
9696
9797 private IdentityManagerResult SetName ( InMemoryUser user , string value )
9898 {
9999 if ( user == null ) throw new ArgumentNullException ( "SetName::" + string . Format ( ExceptionMessages . IsNotAssigned , user ) ) ;
100100 if ( value == null ) throw new ArgumentNullException ( "SetName::" + string . Format ( ExceptionMessages . IsNotAssigned , value ) ) ;
101101
102- user . Claims . SetValue ( Constants . ClaimTypes . Name , value ) ;
102+ user . Claims . SetValue ( IdentityManagerConstants . ClaimTypes . Name , value ) ;
103103 return IdentityManagerResult . Success ;
104104 }
105105
@@ -152,7 +152,7 @@ from u in users
152152 filter = filter . ToLower ( ) ;
153153 query =
154154 from u in query
155- let names = ( from c in u . Claims where c . Type == Constants . ClaimTypes . Name select c . Value . ToLower ( ) )
155+ let names = ( from c in u . Claims where c . Type == IdentityManagerConstants . ClaimTypes . Name select c . Value . ToLower ( ) )
156156 where
157157 u . Username . ToLower ( ) . Contains ( filter ) ||
158158 names . Contains ( filter )
@@ -165,7 +165,7 @@ from u in query.Distinct()
165165 {
166166 Subject = u . Subject ,
167167 Username = u . Username ,
168- Name = u . Claims . Where ( x => x . Type == Constants . ClaimTypes . Name ) . Select ( x => x . Value ) . FirstOrDefault ( ) ,
168+ Name = u . Claims . Where ( x => x . Type == IdentityManagerConstants . ClaimTypes . Name ) . Select ( x => x . Value ) . FirstOrDefault ( ) ,
169169 } ;
170170 var total = items . Count ( ) ;
171171
@@ -200,7 +200,7 @@ public async Task<IdentityManagerResult<UserDetail>> GetUserAsync(string subject
200200 {
201201 Subject = user . Subject ,
202202 Username = user . Username ,
203- Name = user . Claims . GetValue ( Constants . ClaimTypes . Name ) ,
203+ Name = user . Claims . GetValue ( IdentityManagerConstants . ClaimTypes . Name ) ,
204204 Properties = props ,
205205 Claims = user . Claims . Select ( x => new ClaimValue { Type = x . Type , Value = x . Value } )
206206 } ) ;
@@ -245,7 +245,7 @@ private async Task<string> GetUserProperty(PropertyMetadata property, InMemoryUs
245245 switch ( property . Type )
246246 {
247247 case "role.admin" :
248- return user . Claims . HasValue ( Constants . ClaimTypes . Role , "admin" ) . ToString ( ) . ToLower ( ) ;
248+ return user . Claims . HasValue ( IdentityManagerConstants . ClaimTypes . Role , "admin" ) . ToString ( ) . ToLower ( ) ;
249249 case "gravatar" :
250250 return user . Claims . GetValue ( "gravatar" ) ;
251251 }
@@ -267,8 +267,8 @@ private Task<IdentityManagerResult> SetUserProperty(IEnumerable<PropertyMetadata
267267 case "role.admin" :
268268 {
269269 var val = bool . Parse ( value ) ;
270- if ( val ) user . Claims . AddClaim ( Constants . ClaimTypes . Role , "admin" ) ;
271- else user . Claims . RemoveClaim ( Constants . ClaimTypes . Role , "admin" ) ;
270+ if ( val ) user . Claims . AddClaim ( IdentityManagerConstants . ClaimTypes . Role , "admin" ) ;
271+ else user . Claims . RemoveClaim ( IdentityManagerConstants . ClaimTypes . Role , "admin" ) ;
272272 }
273273 break ;
274274 case "gravatar" :
@@ -292,12 +292,12 @@ private IEnumerable<string> ValidateUserProperty(string type, string value)
292292 {
293293 switch ( type )
294294 {
295- case Constants . ClaimTypes . Username :
295+ case IdentityManagerConstants . ClaimTypes . Username :
296296 {
297297 if ( users . Any ( x => x . Username == value ) ) return new [ ] { "That Username is already in use" } ;
298298 }
299299 break ;
300- case Constants . ClaimTypes . Password :
300+ case IdentityManagerConstants . ClaimTypes . Password :
301301 {
302302 if ( value . Length < 3 ) return new [ ] { "Password must have at least 3 characters" } ;
303303 }
0 commit comments