我正在按照步骤Scott Brady的步骤,尝试实现多租户应用程序:
https://www.scottbrady91.com/ASPNET-Identity/Quick-and-Easy-ASPNET-Identity-Multitenancy
我不确定我应该在哪里放置这些代码行:
var context = new ApplicationUserDbContext<ApplicationUser>("DefaultConnection");
var userStore = new ApplicationUserStore<ApplicationUser>(context) { TenantId = 1 };
var userManager = new UserManager<ApplicationUser, string>(userStore);
我试图在AccountController的登录操作中使用它:
var context = new ApplicationDbContext();
var userStore = new ApplicationUserStore<ApplicationUser>(context) { TenantId = tenantId };
UserManager = new ApplicationUserManager(userStore);
SignInManager.UserManager = UserManager;
ApplicationUser userApp =await UserManager.FindByEmailAsync(model.Email);
但是UserManager.FindByEmailAsync
总是返回null
,对如何使它起作用我有什么想法?我真正的目标是给SingIn User,但总是返回Failure。而且我认为问题出在寻找ApplicationUser
。
如果您需要其他信息,请提前告知我。
答案 0 :(得分:0)
您正在直接使用类。尝试使用这种方式...并确保您的用户具有您提供的gmail。
KeyListener keyListener = new KeyListener() {
public void keyPressed(KeyEvent keyEvent) {
printIt("Pressed", keyEvent);
}
public void keyReleased(KeyEvent keyEvent) {
printIt("Released", keyEvent);
}
public void keyTyped(KeyEvent keyEvent) {
printIt("Typed", keyEvent);
}
private void printIt(String title, KeyEvent keyEvent) {
int keyCode = keyEvent.getKeyCode();
String keyText = KeyEvent.getKeyText(keyCode);
System.out.println(title + " : " + keyText + " / " +
keyEvent.getKeyChar());
}
};
txField.addKeyListener(keyListener);