diff --git a/Controllers/Account/AccountController+Admin.cs b/Controllers/Account/AccountController+Admin.cs
deleted file mode 100644
index 013a0fc..0000000
--- a/Controllers/Account/AccountController+Admin.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using xIdentityHelper;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xIdentityModels.Dtos;
-
-namespace xApi.Controllers {
- public partial class AccountController {
- //
- #region Admin Actions ...
- ///
- /// Ban Specific Users
- ///
- /// an instance of XUserNameIdRequest which represents user identifier list to Ban
- /// a list of banned users identifiers
- [RequireXPowered]
- [HttpPost ("Ban")]
- [Authorize (Policy = XPolicies.EnabledAdmin)]
- public async Task>> Ban (
- [FromBody] XUserNameIdRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (model)
- .AddNotZeroChilds (model.Ids)
- .ValidateGroupAsync ();
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .Ban (
- tokens,
- model
- );
-
- //
- return Ok (result)
- .ToDynamicObject ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// UnBann Specific Users
- ///
- /// an instance of XUserNameIdRequest which represents user identifier list to Ban
- /// a list of unbanned users identifiers
- [RequireXPowered]
- [HttpPost ("UnBan")]
- [Authorize (Policy = XPolicies.EnabledAdmin)]
- public async Task>> UnBan (
- [FromBody] XUserNameIdRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (model)
- .AddNotZeroChilds (model.Ids)
- .ValidateGroupAsync ();
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .UnBan (
- tokens,
- model
- );
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Check Specific User is Banned or not
- ///
- /// specified user's identifier
- /// a boolean value which represent user banned or not
- [RequireXPowered]
- [HttpGet ("IsBanned/{userSelectByParam?}")]
- [Authorize (Policy = XPolicies.EnabledAdmin)]
- [Authorize (Policy = XPolicies.EnabledAgent)]
- public async Task> IsBanned (
- [FromRoute] string userSelectByParam = null
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (userSelectByParam.IsNullOrEmpty ()) {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty (userSelectByParam);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .IsBanned (
- tokens,
- userSelectByParam
- );
-
- //
- return Ok (result);
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Authentication.cs b/Controllers/Account/AccountController+Authentication.cs
deleted file mode 100644
index f0749cb..0000000
--- a/Controllers/Account/AccountController+Authentication.cs
+++ /dev/null
@@ -1,388 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using IdentityModel.Client;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using xIdentityHelper;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xExceptions.Constants;
-using xIdentityModels.Models;
-using xModels.Dtos;
-using static xIdentityHelper.XApiScopeHelper;
-
-namespace xApi.Controllers {
- public partial class AccountController {
- //
- #region Authentication Actions ...
- ///
- /// Retrieve OAuth Discovery Document
- ///
- /// an instance of DiscoveryDocumentResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet ("DiscoveryDocument")]
- public async Task> GetDiscoveryDocument () {
- //
- try {
- //
- var result = await identityProvider
- .RequestDiscoveryDocument ();
-
- //
- // Ceck Response Result ...
- if (result.IsError) {
- XException.InvalidConfiguration.Throw ();
- }
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Request AccessToken for Specific XApiScope
- ///
- /// a member of XApiScope
- /// an instance of XTokenResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestScopeAccessToken")]
- public async Task> RequestScopeAccessToken (
- [FromHeader] XApiScope scope
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- var scopeName = string.Empty;
- try {
- scopeName = scope.GetStringValue ();
- } catch { }
- ValidationProvider.NotEmpty (scopeName);
-
- //
- var result = await identityProvider
- .RequestScopeAccessToken (scopeName);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Authenticate User
- ///
- ///
- /// Sample request:
- ///
- /// {
- /// "password": "",
- /// "userSelectBy": "",
- /// }
- ///
- ///
- /// User Login Required Info, an instance of XLoginRequest
- /// an instance of XTokenResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("Authenticate")]
- public async Task> Authenticate (
- [FromBody] XLoginRequest model
- ) {
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (model)
- .AddNotEmpty (
- model.UserSelectBy,
- model.Password
- )
- .ValidateGroupAsync ();
-
- //
- var result = await identityProvider
- .Authenticate (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Authenticate User
- ///
- ///
- /// Sample request:
- ///
- /// {
- /// "language": "fa-IR"
- /// "password": "",
- /// "userSelectBy": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// User Login Required Info, an instance of XLoginRequest
- /// an instance of XLoginResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("Login")]
- public async Task> Login (
- [FromBody] XLoginRequest model
- ) {
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (
- model,
- model.Device)
- .AddNotEmpty (
- model.Language,
- model.UserSelectBy,
- model.Password
- )
- .ValidateGroupAsync ();
-
- //
- var result = await identityProvider
- .Login (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Logout User
- ///
- [RequireXPowered]
- [HttpPost ("Logout")]
- [Authorize (Policy = XPolicies.User)]
- public async Task Logout () {
- try {
- //
- var tokens = await RetrieveTokensAsXTokenResponse ();
- await identityProvider
- .Logout (tokens);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Refresh Expired Tokens
- ///
- ///
- /// in addition to AccessToken, you had to pass RefreshToken due to Headers
- ///
- /// an instance of XTokenResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RefreshTokens")]
- public async Task> RefreshTokens () {
- //
- try {
- //
- // Retrieve Toke Response ...
- var model = await RetrieveTokensAsXTokenResponse ();
-
- //
- // Validate Args ...
- ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (model)
- .AddNotEmpty (
- model.AccessToken,
- model.RefreshToken)
- .ValidateGroup ();
-
- //
- var result = await identityProvider
- .RefreshTokens (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Validate a Revision Checksum
- ///
- ///
- ///
- [HttpPost ("Validate")]
- [Authorize (Policy = XPolicies.EnabledUser)]
- public async Task> Validate (
- [FromBody] XValidateRevisionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (model)
- .AddNotEmpty (model.Revision)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = tokens.ValidateRevisionChecksum (
- model.Revision,
- identityProvider.RevisionSecretKey
- );
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
- #endregion
-
- //
- #region Password Actions ...
- ///
- /// Change a User's Password ...
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Password: user's current active password.
- /// - NewPassword: user's new password to change.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Login URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "password": ""
- /// "newPassword": "",
- /// "returnUrl": "http://localhost/login",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- ///
- [RequireXPowered]
- [HttpPost ("ChangePassword")]
- [Authorize (Policy = XPolicies.User)]
- [Authorize (Policy = XPolicies.EnabledUser)]
- public async Task ChangePassword (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotNull (
- model,
- model.Device
- )
- .AddNotEmpty (
- model.Lang,
- model.Password,
- model.NewPassword,
- model.ReturnUrl
- )
- .ValidateGroupAsync ();
-
- //
- // Get User Select By ...
- var userSelectByParam = GetUserSelectByParam (
- model,
- forceNotNull : false
- );
- if (userSelectByParam.IsNullOrEmpty ()) {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty (userSelectByParam);
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse ();
- await identityProvider
- .ChangePassword (tokens, model);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Friendship.cs b/Controllers/Account/AccountController+Friendship.cs
deleted file mode 100644
index be87931..0000000
--- a/Controllers/Account/AccountController+Friendship.cs
+++ /dev/null
@@ -1,910 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using xIdentityHelper;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xIdentityModels.Constants;
-using xIdentityModels.Dtos;
-using xIdentityModels.Navigations;
-using xModels.Dtos;
-using System.Linq;
-using xExceptions.Constants;
-
-namespace xApi.Controllers
-{
- public partial class AccountController
- {
- //
- #region Friendship Actions ...
- ///
- /// Follow a User
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollowing
- [RequireXPowered]
- [HttpPost("Friendship/{destUser}/Follow")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> Follow(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .Follow(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Cancel Following Request
- ///
- /// a user identifier which represent destination user
- /// a boolean value
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Friendship/{destUser}/Cancel")]
- public async Task> Cancel(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .Cancel(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Unfollow a Follower
- ///
- /// a user identifier which represent destination user
- ///
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Friendship/{destUser}/UnFollowFollower")]
- public async Task UnFollowFollower(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- await identityProvider
- .UnFollowFollower(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok();
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Unfollow Following
- ///
- /// a user identifier which represent destination user
- ///
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Friendship/{destUser}/UnFollowFollowing")]
- public async Task UnFollowFollowing(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- await identityProvider
- .UnFollowFollowing(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok();
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Block a Follower
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollowing
- [HttpPost("Friendship/{destUser}/Block")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> Block(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .Block(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
-
- //
- return exResult;
- }
- }
-
- ///
- /// Unblock a Blocked User
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollowing
- [HttpPost("Friendship/{destUser}/UnBlock")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> UnBlock(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .UnBlock(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Accept a Following Request
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollower
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Friendship/{destUser}/AcceptRequest")]
- public async Task> AcceptRequest(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .AcceptRequest(
- tokens,
- destUser
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Reject a Following Request
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollower
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Friendship/{destUser}/RejectRequest")]
- public async Task> RejectRequest(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .RejectRequest(
- tokens,
- destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
- #endregion
-
- //
- #region Friendship Getters ...
-
- ///
- /// Get Friendship Info Model between Specific User and Current User
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipInfoDto
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/FriendshipInfo")]
- public async Task> FriendshipInfo(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFriendshipInfo(
- tokens,
- destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Check a User IsFollower of Requested User
- ///
- /// a user identifier which represent destination user
- /// a boolean value
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/IsFollower")]
- public async Task> IsFollower(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .IsFollower(
- tokens,
- destUser
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Follower State of a User
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipState
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/FollowerState")]
- public async Task> FollowerState(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowerState(
- tokens,
- destUser
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Specific Follower
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollower
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/Follower")]
- public async Task> Follower(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollower(
- tokens,
- destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Followers List Of Current User
- ///
- /// a collection of XFriendshipFollower
- [HttpGet("Friendship/Followers")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> Followers()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowers(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
-
- //
- return exResult;
- }
- }
-
- ///
- /// Get All Followers List Includes Blocked, Requested and etc
- /// of Current User
- ///
- /// a collection of XFriendshipFollower
- [HttpGet("Friendship/AllFollowers")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> AllFollowers()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetAllFollowers(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get All Followers List Includes Blocked, Requested and etc
- /// of Current User based On Query Model ...
- ///
- /// a Query Result of XFriendDto
- [HttpGet("Friendship/QueryFollowers")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> QueryFollowers(
- [FromQuery] XQuery query,
- [FromQuery] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Normalizing Dest User ...
- var userInfo = await GetUserInfo();
- bool isAdmin = userInfo.Roles.Contains(XUserRoles.ADMIN);
- if (destUser.IsNullOrEmpty())
- {
- destUser = userInfo.UserName;
- }
- bool isDestUserValid = isAdmin || destUser == userInfo.UserId || destUser == userInfo.Email || destUser == userInfo.PhoneNumber || destUser == userInfo.UserName;
- if (!isDestUserValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .QueryFollowers(
- query: query,
- tokens: tokens,
- destUser: destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Check a User is in Followings of Current User
- ///
- /// a user identifier which represent destination user
- /// a boolean value
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/IsFollowing")]
- public async Task> IsFollowing(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .IsFollowing(
- tokens,
- destUser
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Following State Relation between Specific User
- /// and Current User
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipState
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/FollowingState")]
- public async Task> FollowingState(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowingState(
- tokens,
- destUser
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Specific Following Model
- ///
- /// a user identifier which represent destination user
- /// an instance of XFriendshipFollowing
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpGet("Friendship/{destUser}/Following")]
- public async Task> Following(
- [FromRoute] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(destUser);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowing(
- tokens,
- destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get Followings of Current User
- ///
- /// a collection of XFriendshipFollowing
- [HttpGet("Friendship/Followings")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> Followings()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowings(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get All Following List Includes Blocked, Requested and etc
- /// of Current User
- ///
- /// a collection of XFriendshipFollowing
- [HttpGet("Friendship/AllFollowings")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> AllFollowings()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetAllFollowings(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Return Following UserName's List of Current User
- ///
- /// a collection of UserNames
- [HttpGet("Friendship/FollowingsList")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> FollowingsList()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowingList(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Return Followers UserName's List of Current User
- ///
- /// a collection of UserNames
- [HttpGet("Friendship/FollowersList")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> FollowersList()
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetFollowersList(tokens);
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Get All Followings List Includes Blocked, Requested and etc
- /// of Current User based On Query Model ...
- ///
- /// a Query Result of XFriendDto
- [HttpGet("Friendship/QueryFollowings")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> QueryFollowings(
- [FromQuery] XQuery query,
- [FromQuery] string destUser
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Normalizing Dest User ...
- var userInfo = await GetUserInfo();
- bool isAdmin = userInfo.Roles.Contains(XUserRoles.ADMIN);
- if (destUser.IsNullOrEmpty())
- {
- destUser = userInfo.UserName;
- }
- bool isDestUserValid = isAdmin || destUser == userInfo.UserId || destUser == userInfo.Email || destUser == userInfo.PhoneNumber || destUser == userInfo.UserName;
- if (!isDestUserValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .QueryFollowings(
- query: query,
- tokens: tokens,
- destUser: destUser
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Open.cs b/Controllers/Account/AccountController+Open.cs
deleted file mode 100644
index cd1a9fa..0000000
--- a/Controllers/Account/AccountController+Open.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xModels.Dtos;
-
-namespace xApi.Controllers
-{
- public partial class AccountController
- {
- #region Open Actions ...
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet("GetUserInfo")]
- public async Task> GetUserInfo(
- [FromHeader] string token,
- [FromQuery] string request
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder()
- .AddNotEmpty(token)
- .AddNotEmpty(request)
- .ValidateGroupAsync();
-
- //
- var result = await identityProvider.GetUserInfo(
- token: token,
- request: request
- );
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet("GetUserInfoByDevice")]
- public async Task> GetUserInfoByDevice(
- [FromQuery] string userSelectByParam,
- [FromBody] XDeviceDto device
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder()
- .AddNotEmpty(userSelectByParam)
- .AddNotNull(device)
- .ValidateGroupAsync();
-
- //
- var result = await identityProvider.GetUserInfo(
- userSelectByParam: userSelectByParam,
- device: device
- );
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Profile.cs b/Controllers/Account/AccountController+Profile.cs
deleted file mode 100644
index 9436e1d..0000000
--- a/Controllers/Account/AccountController+Profile.cs
+++ /dev/null
@@ -1,528 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using xIdentityHelper;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xIdentityModels.Dtos;
-using xIdentityModels.Models;
-using xModels.Dtos;
-
-namespace xApi.Controllers
-{
- public partial class AccountController
- {
- //
- #region Retrieve Actions ...
- ///
- /// Retrieve User Names based on UserIds
- ///
- /// a comma seperated list of UserIds
- /// a collection of UserNames
- [RequireXPowered]
- [HttpGet("Profile/{ids}/GetNames")]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> GetNames(
- [FromRoute] string ids
- )
- {
- //
- // Do Action ...
- try
- {
- //
- ValidationProvider.NotEmpty(ids);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.GetUserNames(
- tokens,
- ids
- );
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// get user ids and retrieve corresponding user names
- ///
- /// an instance of XUserNameIdRequest which represent required UserIds collection
- /// a collection of XUserNameIdResponse instance
- [RequireXPowered]
- [HttpPost("Profile/GetNameIds")]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> GetNameIds(
- [FromBody] XUserNameIdRequest model
- )
- {
- //
- // Do Action ...
- try
- {
- //
- ValidationProvider.NotNull(model);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.GetUserNameIds(
- tokens,
- model
- );
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Get Profile Object of Specific User
- ///
- /// determine's which user profile must be retrieved
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [Authorize(Policy = XPolicies.User)]
- [HttpGet("Profile/{userSelectByParam?}")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> GetProfile(
- [FromRoute] string userSelectByParam = ""
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- if (userSelectByParam.IsNullOrEmpty())
- {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty(userSelectByParam);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .GetUserProfile(
- tokens,
- userSelectByParam
- );
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Query Users
- /// for specifiy users role for query user 'role: string' and 'forceRole: boolean' in header
- ///
- /// how to filter results based on XQuery structure
- /// an string which represent user role
- /// if it's true the user must has exact role, otherwise top level users also listed
- /// an instance of XQueryResult of XUserProfileDto
- [RequireXPowered]
- [HttpGet("Profile/Query")]
- [Authorize(Policy = XPolicies.EnabledAdmin)]
- [Authorize(Policy = XPolicies.EnabledAgent)]
- public async Task>> QueryProfiles(
- [FromQuery] XQuery query, [FromHeader] string role, [FromHeader] bool forceRole = false
- )
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = new XQueryResult();
- if (role.IsNullOrEmpty())
- {
- //
- result = await identityProvider.QueryUsers(
- tokens,
- query
- );
- }
- else
- {
- //
- result = await identityProvider.QueryInRoleUsers(
- tokens,
- role,
- query,
- forceRole
- );
- }
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exception = GetExceptionActionResult(ex);
- return exception;
- }
- }
-
- ///
- /// Query Specified User's Profile Images
- ///
- /// determine's which user profile must be retrieved
- /// how to filter results based on XQuery structure
- /// an instance of XQueryResult of XProfileImage
- [RequireXPowered]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- [Authorize(Policy = XPolicies.EnabledAdmin)]
- [HttpGet("Profile/Avatars/Query/{userSelectByParam?}")]
- public async Task>> QueryAvatars(
- [FromQuery] XQuery query, [FromRoute] string userSelectByParam = null
- )
- {
- //
- // Do Action ...
- try
- {
- //
- if (userSelectByParam.IsNullOrEmpty())
- {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty(userSelectByParam);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.QueryAvatars(
- tokens,
- userSelectByParam,
- query
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exception = GetExceptionActionResult(ex);
- return exception;
- }
- }
- #endregion
-
- //
- #region Update Actions ...
- ///
- /// Update User Profile based on XProfileUpdateRequest (FirstName/LastName/DateOfBirth)
- ///
- /// user update info, an instance of XProfileUpdateRequest
- /// determine's which user profile must be retrieved
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [Authorize(Policy = XPolicies.EnabledUser)]
- [HttpPost("Profile/Update/{userSelectByParam?}")]
- public async Task> UpdateProfile(
- [FromBody] XProfileUpdateRequest model, [FromRoute] string userSelectByParam = null
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- if (userSelectByParam.IsNullOrEmpty())
- {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty(userSelectByParam);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.ProfileUpdateAsync(
- tokens,
- userSelectByParam,
- model
- );
-
- //
- // Prepare Push Message ...
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Update a User Profile based on XProfileUpdateRequest Full
- ///
- /// user update info, an instance of XProfileUpdateRequest
- /// determine's which user profile must be retrieved
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [HttpPost("Profile/{userSelectByParam?}")]
- [Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
- public async Task> FullUpdateProfile(
- [FromBody] XProfileUpdateRequest model, [FromRoute] string userSelectByParam = null
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- if (userSelectByParam.IsNullOrEmpty())
- {
- userSelectByParam = User.Identity.Name;
- }
- ValidationProvider.NotEmpty(userSelectByParam);
-
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.FullProfileUpdateAsync(
- tokens,
- userSelectByParam,
- model
- );
-
- //
- // Prepare Push Message ...
-
- //
- // Return Result
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
- #endregion
-
- //
- #region Avatar Actions ...
- ///
- /// Add a New Profile Image
- ///
- /// an specific File to upload, IFormFile
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [HttpPost("Profile/Avatar")]
- [RequestSizeLimit(966_367_641)]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> AddAvatar(
- [FromForm] IFormFile file
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotNull(file);
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .AddAvatar(
- tokens,
- file
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// Add a New Collection of Profile Images
- ///
- /// a collection of Files to upload, IFormFileCollection
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [HttpPost("Profile/Avatars")]
- [RequestSizeLimit(966_367_641)]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> AddAvatars(
- [FromForm] IFormFileCollection files
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotZeroChilds(files);
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.AddAvatars(
- tokens,
- files
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exResult = GetExceptionActionResult(ex);
- return exResult;
- }
- }
-
- ///
- /// set Specified Profile Image as Avatar
- ///
- /// an integer which reperesent AvatarId to set as current Avatar
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [HttpPost("Profile/Avatars/{id:int}/Set")]
- [Authorize(Policy = XPolicies.User)]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> SetAvatar(
- [FromRoute] int id
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .SetAvatar(
- tokens,
- id
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exception = GetExceptionActionResult(ex);
- return exception;
- }
- }
-
- ///
- /// Remove Profile Images
- ///
- /// a comma seperated list of avatarIds to remove
- /// an instance of XUserProfileDto
- [RequireXPowered]
- [Authorize(Policy = XPolicies.User)]
- [HttpDelete("Profile/Avatars/{ids}")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task> RemoveAvatars(
- [FromRoute] string ids
- )
- {
- //
- // Do Action ...
- try
- {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty(ids);
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider
- .RemoveAvatars(
- tokens,
- ids
- );
-
- //
- // Prepare Push Message ...
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Registration.cs b/Controllers/Account/AccountController+Registration.cs
deleted file mode 100644
index dca93d5..0000000
--- a/Controllers/Account/AccountController+Registration.cs
+++ /dev/null
@@ -1,1142 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using xIdentityHelper;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xExceptions.Constants;
-using xIdentityModels.Constants;
-using xIdentityModels.Extensions;
-using xIdentityModels.Models;
-
-namespace xApi.Controllers {
- public partial class AccountController {
- //
- #region Registration ...
- ///
- /// Check a UserName is Available For Registration or not
- ///
- /// an string value which represent desired username
- /// a boolean value
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet ("CanRegisterUserName/{userName?}")]
- public async Task> CanRegisterUserName (
- [FromRoute] string userName
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty (userName);
-
- //
- // Validate Type ...
- var type = userName.GetUserSelectByType ();
- if (type != XUserSelectBy.Username) {
- XException.InvalidArgs.Throw ();
- }
-
- //
- var result = await identityProvider
- .CanRegister (userName);
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
-
- //
- return result;
- }
- }
-
- ///
- /// Check a Mobile Number is Available For Registration or not
- ///
- /// an string value which represent desired mobile number
- /// a boolean value
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet ("CanRegisterMobileNumber/{mobileNumber?}")]
- public async Task> CanRegisterMobileNumber (
- [FromRoute] string mobileNumber
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty (mobileNumber);
-
- //
- // Validate Type ...
- var type = mobileNumber.GetUserSelectByType ();
- if (type != XUserSelectBy.MobileNumber) {
- XException.InvalidArgs.Throw ();
- }
-
- //
- var result = await identityProvider
- .CanRegister (mobileNumber);
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
-
- //
- return result;
- }
- }
-
- ///
- /// Check a Email Address is Available For Registration or not
- ///
- /// an string value which represent desired email address
- /// a boolean value
- [AllowAnonymous]
- [RequireXPowered]
- [HttpGet ("CanRegisterEmail/{email?}")]
- public async Task> CanRegisterEmail (
- [FromRoute] string email
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- ValidationProvider.NotEmpty (email);
-
- //
- // Validate Type ...
- var type = email.GetUserSelectByType ();
- if (type != XUserSelectBy.Email) {
- XException.InvalidArgs.Throw ();
- }
-
- //
- var result = await identityProvider
- .CanRegister (email);
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
-
- //
- return result;
- }
- }
-
- ///
- /// Invite a User to Register on Dashboard
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Email: which email address is going to invite.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Registration URL.
- /// notice in this step you had to provide all this informations as FormData
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "email": "",
- /// "returnUrl": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [RequireXPowered]
- [HttpPost ("InviteUser")]
- [Authorize (Policy = XPolicies.EnabledAdmin)]
- [Authorize (Policy = XPolicies.EnabledAgent)]
- public async Task> InviteUser (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
-
- //
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.Email,
- model.ReturnUrl)
- .AddEmailAddress (model.Email)
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .InviteUser (
- tokens,
- model
- );
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
- return result;
- }
- }
-
- ///
- /// Recieve some Basic Informations and Start Registration Proccess
- /// if they Valid
- ///
- /// Registration Proccess Starts with Invoking this Action
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - FirstName: user's FirstName.
- /// - LastName: user's LastName.
- /// - DateOfBirth: user's dob date.
- /// - MobileNumber: user's MobileNumber optional.
- /// - Email: user's Email optional.
- /// - ActionToken: user's requested action token for this action (if user invited).
- /// - Device: user's client device which is an instance of XDevice.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "firstName": "",
- /// "lastName": "",
- /// "dateOfBirth": "",
- /// "email": "",
- /// "mobileNumber": "",
- /// "actionToken": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestRegistration")]
- public async Task> RequestRegistration (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.FirstName,
- model.LastName)
- .AddNotNull (
- model.Device,
- model.DateOfBirth)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var result = await identityProvider
- .RequestRegistration (
- model
- );
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
-
- //
- return exResult;
- }
- }
-
- ///
- /// Add User Account Informations
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - UserName: user name.
- /// - Password: assigne password.
- /// - Device: user's client device which is an instance of XDevice.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "userName": "",
- /// "password": "",
- /// "actionToken": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("AddAccountInfo")]
- public async Task> AddAccountInfo (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.ActionToken,
- model.UserName,
- model.Password)
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var result = await identityProvider
- .AddAccountInfo (
- model
- );
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Upload and Attach a Profile Image for User. this is an Optional Step
- ///
- /// user's requested action token
- /// an instance of IFormFile for user's Avatar
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("AttachProfileImage")]
- public async Task> AttachProfileImage (
- [FromForm] string actionToken, [FromForm] IFormFile file
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (actionToken)
- .AddNotNull (file)
- .ValidateGroupAsync ();
-
- //
- var result = await identityProvider
- .AttachProfileImage (
- actionToken,
- file
- );
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Finish Registrationn Proccess
- ///
- ///
- /// for this action you have to provide:
- /// - a proper User Identifier such as: (UserId, UserName, Email or MobileNumber).
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - Password: assigne password.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Login URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "userName": "",
- /// "password": "",
- /// "returnUrl": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- ///
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("FinishRegistration")]
- public async Task FinishRegistration (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.Password,
- model.ReturnUrl)
- .AddNotNull (model.Device)
- .AddUrl (model.ReturnUrl)
- .ValidateGroupAsync ();
-
- //
- var userSelectByParam = identityProvider
- .GetUserSelectByParam (model);
- ValidationProvider
- .NotEmpty (userSelectByParam);
-
- //
- // Get Request ...
- await identityProvider
- .FinishRegistration (model);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
-
- //
- return exResult;
- }
- }
-
- ///
- /// Check User is Confirmed Email or not
- ///
- /// a boolean value
- [RequireXPowered]
- [HttpGet ("IsConfirmedEmail")]
- [Authorize (Policy = XPolicies.User)]
- public async Task> IsConfirmedEmail () {
- //
- // Do Action ...
- try {
- //
- // Get Result ...
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .IsConfirmedEmail (
- tokens,
- User.Identity.Name
- );
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
-
- //
- return result;
- }
- }
-
- ///
- /// Check User is Confirmed Mobile or not
- ///
- /// a boolean value
- [RequireXPowered]
- [HttpGet ("IsConfirmedMobile")]
- [Authorize (Policy = XPolicies.User)]
- public async Task> IsConfirmedMobile () {
- //
- // Do Action ...
- try {
- //
- // Get Result ...
- var tokens = await RetrieveTokensAsXTokenResponse ();
- var result = await identityProvider
- .IsConfirmedMobile (
- tokens,
- User.Identity.Name
- );
-
- //
- // Return Result
- return Ok (result);
- } catch (Exception ex) {
- //
- var result = GetExceptionActionResult (ex);
-
- //
- return result;
- }
- }
-
- ///
- /// Request Registration Confirm
- ///
- ///
- /// for this action you have to provide:
- /// - a UserSelectedBy identifier which represet User.
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Password: user's current active password.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Confirm Registration URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "userId": ""
- /// "password": "",
- /// "returnUrl": "http://localhost/confirm",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- ///
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestConfirmRegistration")]
- public async Task RequestConfirmRegistration (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.Password,
- model.ReturnUrl)
- .AddNotNull (model.Device)
- .AddUrl (model.ReturnUrl)
- .ValidateGroupAsync ();
-
- //
- // Get UserSelect By Param ...
- var userSelectByParam = model.GetUserSelectByParam ();
- ValidationProvider.NotEmpty (userSelectByParam);
-
- //
- await identityProvider
- .RequestConfirmRegistration (model);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Confirm Registration
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Login URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "actionToken": ""
- /// "returnUrl": "http://localhost/login",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- ///
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("ConfirmRegistration")]
- public async Task ConfirmRegistration (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.ActionToken,
- model.ReturnUrl
- )
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- await identityProvider
- .ConfirmRegistration (model);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Request For Mobile Number Change/Confirm
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Password: user's current active password.
- /// - MobileNumber: which phone number is going to confirm.
- /// - Device: user's client device which is an instance of XDevice.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "password": "",
- /// "mobileNumber": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestConfirmMobile")]
- public async Task> RequestConfirmMobile (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.Password,
- model.MobileNumber)
- .AddNotNull (model.Device)
- .AddMobileNumber (model.MobileNumber)
- .ValidateGroupAsync ();
-
- //
- // Get UserSelect By Param ...
- var userSelectByParam = GetUserSelectByParam (
- model,
- excludes : new List {
- XUserSelectBy.Email,
- XUserSelectBy.MobileNumber
- });
-
- //
- // Get Request ...
- var result = await identityProvider
- .RequestConfirmMobile (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Confirm Requested Mobile Number
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - Device: user's client device which is an instance of XDevice.
- /// - MobileVerificationCode: a verification code which produced due Request Action.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "actionToken": ""
- /// "mobileVerificationCode": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("ConfirmMobileNumber")]
- public async Task> ConfirmMobileNumber (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.MobileVerificationCode,
- model.ActionToken
- )
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var result = await identityProvider
- .ConfirmMobileNumber (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Request For Email Address Change/Confirm
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Password: user's current active password.
- /// - Email: which email address is going to confirm.
- /// - Device: user's client device which is an instance of XDevice.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "password": "",
- /// "email": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestConfirmEmail")]
- public async Task> RequestConfirmEmail (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.Email,
- model.Password)
- .AddNotNull (model.Device)
- .AddEmailAddress (model.Email)
- .ValidateGroupAsync ();
-
- //
- // Get UserSelect By Param ...
- var userSelectByParam = GetUserSelectByParam (
- model,
- excludes : new List {
- XUserSelectBy.Email,
- XUserSelectBy.MobileNumber
- });
-
- //
- // Get Request ...
- var result = await identityProvider
- .RequestConfirmEmail (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Confirm Requested Email Address
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - Device: user's client device which is an instance of XDevice.
- /// - EmailVerificationCode: a verification code which produced due Request Action.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "actionToken": ""
- /// "emailVerificationCode": "",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("ConfirmEmailAddress")]
- public async Task> ConfirmEmailAddress (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.EmailVerificationCode,
- model.ActionToken
- )
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- var result = await identityProvider
- .ConfirmEmailAddress (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Request Reset Password Action
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application ResetPassword URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "returnUrl": "http://localhost/reset-password",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- /// an instance of XActionResponse
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("RequestResetPassword")]
- public async Task> RequestResetPassword (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.ReturnUrl)
- .AddNotNull (model.Device)
- .AddUrl (model.ReturnUrl)
- .ValidateGroupAsync ();
-
- //
- // Get UserSelect By Param ...
- var userSelectByParam = GetUserSelectByParam (
- model,
- excludes : new List {
- XUserSelectBy.Email,
- XUserSelectBy.MobileNumber
- });
-
- //
- // Get Request ...
- var result = await identityProvider
- .RequestResetPassword (model);
-
- //
- return Ok (result
- .ToDynamicObject ());
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
-
- ///
- /// Reset a User's Password
- ///
- ///
- /// for this action you have to provide:
- /// - Lang: client device currently used locale, such as: en-US.
- /// - ActionToken: user's requested action token for this action.
- /// - NewPassword: user's new password to change.
- /// - Device: user's client device which is an instance of XDevice.
- /// - ReturnUrl: client application Login URL.
- ///
- /// Sample request:
- ///
- /// {
- /// "lang": "fa-IR",
- /// "actionToken": "",
- /// "newPassword": "",
- /// "returnUrl": "http://localhost/login",
- /// "device": {
- /// "os":"Mac",
- /// "browser":"Chrome",
- /// "osVersion":"mac-os-x-15",
- /// "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36",
- /// "deviceType":3,
- /// "identifier":"[Mac]-[mac-os-x-15]-[3]-[Chrome]-[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) x-framework-test/0.0.0 Chrome/87.0.4280.141 Electron/11.2.0 Safari/537.36]",
- /// "token":"96f400dd9aa5c57a8cec9d6f4775bad3"
- /// }
- /// }
- ///
- ///
- /// an instance of XActionRequest class which provider requirement for action
- ///
- [AllowAnonymous]
- [RequireXPowered]
- [HttpPost ("ResetPassword")]
- public async Task ResetPassword (
- [FromBody] XActionRequest model
- ) {
- //
- // Do Action ...
- try {
- //
- // Validate Args ...
- if (!ModelState.IsValid) {
- XException.InvalidArgs.Throw ();
- }
- await ValidationProvider
- .GroupValidationBuilder ()
- .AddNotEmpty (
- model.Lang,
- model.ActionToken,
- model.NewPassword,
- model.ReturnUrl)
- .AddNotNull (model.Device)
- .ValidateGroupAsync ();
-
- //
- // Get Request ...
- await identityProvider
- .ResetPassword (model);
-
- //
- return Ok ();
- } catch (Exception ex) {
- //
- var exResult = GetExceptionActionResult (ex);
- return exResult;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/Account/AccountController+Search.cs b/Controllers/Account/AccountController+Search.cs
deleted file mode 100644
index fdf3c68..0000000
--- a/Controllers/Account/AccountController+Search.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using xCommons.Attributes;
-using xCommons.Extensions;
-using xIdentityHelper;
-using xIdentityModels.Dtos;
-using xModels.Dtos;
-
-namespace xApi.Controllers
-{
- public partial class AccountController
- {
- //
- #region Actions ...
- ///
- /// Query Open To Search Users Profiles ...
- /// Query all Users Which their Profiles is Open To Search ...
- ///
- /// how to filter results based on XQuery structure
- /// an instance of XQueryResult of XUserProfileDto
- [RequireXPowered]
- [HttpGet("OpenToSearch/Query")]
- [Authorize(Policy = XPolicies.EnabledUser)]
- public async Task>> QueryOpenToSearchProfiles(
- [FromQuery] XQuery query
- )
- {
- //
- // Do Action ...
- try
- {
- //
- var tokens = await RetrieveTokensAsXTokenResponse();
- var result = await identityProvider.QueryOpenToSearchUsers(
- tokens,
- query
- );
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var exception = GetExceptionActionResult(ex);
- return exception;
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Controllers/AccountController.cs b/Controllers/AccountController.cs
index 01a29a2..2b69f73 100644
--- a/Controllers/AccountController.cs
+++ b/Controllers/AccountController.cs
@@ -1,25 +1,13 @@
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.Extensions.Logging;
-using xCommons.Attributes;
-using xCommons.Configurations;
using xCommons.Providers;
-using xIdentityService.Controllers;
+using xCommons.Configurations;
+using xIdentityHelper.Controllers;
using xIdentityService.Interfaces;
+using Microsoft.Extensions.Logging;
namespace xApi.Controllers
{
- ///
- /// Handle all Account Related Actions ...
- ///
- [AllowAnonymous]
- [RequireXPowered(true)]
- public partial class AccountController : XBaseIdentityController
+ public partial class AccountController : XAccountControllerBase
{
- //
- #region Props ...
- private readonly IXIdentityProvider identityProvider;
- #endregion
-
//
#region Constructor ...
public AccountController(
@@ -33,10 +21,7 @@ namespace xApi.Controllers
identityProvider,
validationProvider
)
- {
- //
- this.identityProvider = identityProvider;
- }
+ { }
#endregion
}
}
\ No newline at end of file