public async Task <IActionResult> Index() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); var protectorSendGrid = protectorProvider.CreateProtector(_dataProtectionKeys.SendGridProtectionKey); var dashboard = new DashBoardModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, SmtpOption = _writableSvcSmtpOptions.Value, SendGridOption = _writableSvcSendGridOptions.Value, SiteWideSetting = _writableSiteWideSettings.Value, Dashboard = dashboard }; _adminBaseViewModel.SendGridOption.SendGridKey = protectorSendGrid.Protect(_adminBaseViewModel.SendGridOption.SendGridKey); _adminBaseViewModel.SmtpOption.SmtpPassword = protectorSendGrid.Protect(_adminBaseViewModel.SmtpOption.SmtpPassword); return(View("Index", _adminBaseViewModel)); }
public async Task <IActionResult> Index() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, SiteWideSetting = _writableSiteWideSettings.Value, PermissionTypes = (List <PermissionType>) await _roleSvc.GetAllRolePermissionsTypesAsync() }; return(View("Index", _adminBaseViewModel)); }
private async Task SetAdminBaseViewModel() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var resetPassword = new ResetPasswordViewModel(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = null, AppSetting = null, Dashboard = null, ResetPassword = resetPassword, SiteWideSetting = _writableSiteWideSettings.Value }; }
public async Task <IActionResult> Index() { var protectorProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectorProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var userProfile = await _userSvc.GetUserProfileByIdAsync(protector.Unprotect(_cookieSvc.Get("user_id"))); var addUserModel = new AddUserModel(); var dashboard = await _dashboardSvc.GetDashboardData(); _adminBaseViewModel = new AdminBaseViewModel { Profile = userProfile, AddUser = addUserModel, AppSetting = _appSettings, Dashboard = dashboard, SiteWideSetting = _writableSiteWideSettings.Value }; return(View("Index", _adminBaseViewModel)); }
private async Task SetBaseViewModel() { var protectedUid = _cookieSvc.Get("user_id"); //If here is some problems , we should using denpendency injection var protectProvider = _provider.GetService <IDataProtectionProvider>(); var protector = protectProvider.CreateProtector(_dataProtectionKeys.ApplicationUserKey); var unprotectedUID = protector.Unprotect(protectedUid); var userProfile = await _userSvc.GetUserProfileByIdAsync(unprotectedUID); var resetPassword = new ResetPasswordViewModel(); _adminBaseViewModel = new AdminBaseViewModel() { Profile = userProfile, AddUser = null, Dashboard = null, AppSetting = null, SendGridOption = null, SmtpOption = null, ResetPassword = null, SiteWideSetting = null }; }