Hi @enisn,
Can't we use TenantSettingValueProvider
?
This is also a kind of setting manager right ?
Is there any answer for this question ?
@albert Please reply.
I was able to validate user credentitals using await _signInManager.CheckPasswordSignInAsync()
Now I just want to know below things, This is angular login component code
login(params: LoginParams): Observable<any>; Which backend method is called when the above method is called from angular component ?
May be I can make a wrapper method and call this backend login method in my method once I done with my requirement.
import { Injector } from '@angular/core';
import { Params } from '@angular/router';
import { Observable } from 'rxjs';
import { LoginParams } from '../strategies/auth-flow.strategy';
import * as ɵngcc0 from '@angular/core';
export declare class AuthService {
protected injector: Injector;
private strategy;
get isInternalAuth(): boolean;
constructor(injector: Injector);
init(): Promise<any>;
logout(queryParams?: Params): Observable<any>;
/**
* @deprecated Use navigateToLogin method instead. To be deleted in v5.0
*/
initLogin(): void;
navigateToLogin(queryParams?: Params): void;
login(params: LoginParams): Observable<any>;
static ɵfac: ɵngcc0.ɵɵFactoryDef<AuthService, never>;
}
Can you share a simple project?
No I can't.Sorry May be we can have a section and you can have a look into my project.
Can you share some steps and code to reproduce this? Thanks
I just check some permissions from IAuthorizationService and if not success I threw this error
throw new AbpAuthorizationException("...");
Sorry for the delay
Hi,
Thanks for the example. I achieved my Login restriction requirement by Overriding SignInManager.CanSignInAsync();
But I am still stuck in the below issue Can you reply on this for roles : How I did for user can I do it for roles ? check below code I am not able to access individual record and update it added property. Once this is done we can close this ticket
public async Task<bool> MakeUserInactiveOnDormacyDaysCompletionAsync(Guid userId)
{
try
{
var user = await _appUserRepository.GetAsync(userId);
if (user != null)
{
user.Status = AbpUserStatusEnum.InActive;
await _appUserRepository.UpdateAsync(user);
}
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
Hi liangshiwei,
Try
I tried this but this is not working, Can we connect once ?
var users = (await _roleRepository.GetDbSetAsync()).Where(x => EF.Property<int>(x, "PropertyAdded") == 1).ToListAsync();
Below code is working for user. In same way I want to do it for role. But there is no class like AppRoles, help me with this as well
public async Task<bool> MakeUserInactiveOnDormacyDaysCompletionAsync(Guid userId)
{
try
{
var user = await _appUserRepository.GetAsync(userId);
if (user != null)
{
user.Status = AbpUserStatusEnum.InActive;
await _appUserRepository.UpdateAsync(user);
}
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
Hi,
I have already implemented it in seperate identity project
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(AbpSignInManager), typeof(SignInManager<Volo.Abp.Identity.IdentityUser>))]
public class LitmusSiginManager : AbpSignInManager
{
private readonly IRepository<AppUser, Guid> _appUserRepository;
public LitmusSiginManager(IdentityUserManager userManager,
IHttpContextAccessor contextAccessor,
IUserClaimsPrincipalFactory<Volo.Abp.Identity.IdentityUser> claimsFactory,
IOptions<IdentityOptions> optionsAccessor,
ILogger<SignInManager<Volo.Abp.Identity.IdentityUser>> logger,
IAuthenticationSchemeProvider schemes,
IUserConfirmation<Volo.Abp.Identity.IdentityUser> confirmation,
IOptions<AbpIdentityOptions> options,
IRepository<AppUser, Guid> appUserRepository
) : base(userManager,
contextAccessor,
claimsFactory,
optionsAccessor,
logger,
schemes,
confirmation,
options)
{
_appUserRepository = appUserRepository;
}
public override async Task<SignInResult> PasswordSignInAsync(Volo.Abp.Identity.IdentityUser user, string password, bool isPersistent, bool lockoutOnFailure)
{
var appUser = await _appUserRepository.FirstOrDefaultAsync(x => x.Id == user.Id);
if (appUser != null)
{
if (appUser.Status == AbpUserStatusEnum.InActive)
throw new AbpAuthorizationException("User is in InActive state.");
}
return base.PasswordSignInAsync(user, password, isPersistent, lockoutOnFailure).Result;
}
}
Actually I need to work when I log in from angular. I tried as per you gif to login via https://localhost:44350/Account/Login But I am getting this error :
"Status" is the extra column I added to AbpUsers table : reference https://support.abp.io/QA/Questions/1826/Customizing-Application-Modules-Extending-User-Entity-ie-ApbUsers When I do this same logic in some application layer it works fine. I don't understand why I am getting this error here
Note : My debugger was not hit for method PasswordSignInAsync()
typeof(SignInManager<IdentityUser>)
Hi, Even with this its not working