/// <summary> /// Authenticates the admin user. /// </summary> /// <param name="accessCredential">The access credential.</param> /// <returns>AdminSession.</returns> public AdminAuthenticationResult AuthenticateAdminUser(AccessCredential accessCredential) { try { accessCredential.CheckNullObject("accessCredential"); AdminUserInfo userInfo = null; using (var controller = new AdminUserInfoAccessController()) { userInfo = controller.AuthenticateAdminUser(accessCredential); } if (userInfo != null) { using (var controller = new AdminSessionAccessController(adminExpiration)) { var session = controller.CreateAdminSession(new AdminSession { IpAddress = ContextHelper.IpAddress, UserAgent = ContextHelper.UserAgent, OwnerKey = userInfo.Key }); return new AdminAuthenticationResult { TokenExpiredStamp = session.ExpiredStamp, Token = session.Token, UserInfo = userInfo }; } } } catch (Exception ex) { throw ex.Handle( accessCredential); } return null; }
/// <summary> /// Authenticates the third party identifier. /// </summary> /// <param name="thirdPartyId">The third party identifier.</param> /// <returns>AdminAuthenticationResult.</returns> public AdminAuthenticationResult AuthenticateThirdPartyId(string thirdPartyId) { try { thirdPartyId.CheckEmptyString("thirdPartyId"); AdminUserInfo userInfo = null; using (var controller = new AdminUserInfoAccessController()) { userInfo = controller.QueryAdminUserInfo(new AdminUserCriteria { ThirdPartyId = thirdPartyId }).FirstOrDefault(); } if (userInfo != null) { using (var controller = new AdminSessionAccessController(adminExpiration)) { var session = controller.CreateAdminSession(new AdminSession { IpAddress = ContextHelper.IpAddress, UserAgent = ContextHelper.UserAgent, OwnerKey = userInfo.Key }); return new AdminAuthenticationResult { TokenExpiredStamp = session.ExpiredStamp, Token = session.Token, UserInfo = userInfo }; } } } catch (Exception ex) { throw ex.Handle( thirdPartyId); } return null; }
/// <summary> /// Signs the out. /// </summary> /// <param name="token">The token.</param> public void SignOut(string token) { try { token.CheckEmptyString("token"); using (var controller = new AdminSessionAccessController(adminExpiration)) { controller.DeleteAdminSession(token); } } catch (Exception ex) { throw ex.Handle( token); } }