File tree Expand file tree Collapse file tree 4 files changed +44
-7
lines changed
BotSharp.Core/Users/Services
BotSharp.OpenAPI/Controllers Expand file tree Collapse file tree 4 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,6 @@ public interface IUserService
10
10
Task < Token > ActiveUser ( UserActivationModel model ) ;
11
11
Task < Token ? > GetToken ( string authorization ) ;
12
12
Task < User > GetMyProfile ( ) ;
13
+ Task < bool > VerifyUserUnique ( string userName ) ;
14
+ Task < bool > VerifyEmailUnique ( string email ) ;
13
15
}
Original file line number Diff line number Diff line change @@ -13,17 +13,14 @@ public int Page
13
13
14
14
public int Size
15
15
{
16
- get
16
+ get
17
17
{
18
- if ( _size <= 0 ) return 20 ;
19
- if ( _size > 100 ) return 100 ;
20
-
21
18
return _size ;
22
- }
23
- set
19
+ }
20
+ set
24
21
{
25
22
_size = value ;
26
- }
23
+ }
27
24
}
28
25
29
26
/// <summary>
Original file line number Diff line number Diff line change @@ -263,4 +263,30 @@ record = db.GetUserByUserName(id);
263
263
} ;
264
264
return token ;
265
265
}
266
+
267
+ public async Task < bool > VerifyUserUnique ( string userName )
268
+ {
269
+ if ( string . IsNullOrEmpty ( userName ) )
270
+ return false ;
271
+
272
+ var db = _services . GetRequiredService < IBotSharpRepository > ( ) ;
273
+ var user = db . GetUserByUserName ( userName ) ;
274
+ if ( user == null )
275
+ return true ;
276
+
277
+ return false ;
278
+ }
279
+
280
+ public async Task < bool > VerifyEmailUnique ( string email )
281
+ {
282
+ if ( string . IsNullOrEmpty ( email ) )
283
+ return false ;
284
+
285
+ var db = _services . GetRequiredService < IBotSharpRepository > ( ) ;
286
+ var emailName = db . GetUserByEmail ( email ) ;
287
+ if ( emailName == null )
288
+ return true ;
289
+
290
+ return false ;
291
+ }
266
292
}
Original file line number Diff line number Diff line change @@ -94,4 +94,16 @@ public async Task<UserViewModel> GetMyUserProfile()
94
94
}
95
95
return UserViewModel . FromUser ( user ) ;
96
96
}
97
+
98
+ [ HttpGet ( "/user/name/existing" ) ]
99
+ public async Task < bool > VerifyUserUnique ( [ FromQuery ] string userName )
100
+ {
101
+ return await _userService . VerifyUserUnique ( userName ) ;
102
+ }
103
+
104
+ [ HttpGet ( "/user/email/existing" ) ]
105
+ public async Task < bool > VerifyEmailUnique ( [ FromQuery ] string email )
106
+ {
107
+ return await _userService . VerifyEmailUnique ( email ) ;
108
+ }
97
109
}
You can’t perform that action at this time.
0 commit comments