IntegrityError when saving user with username=email
By : devwiz
Date : March 29 2020, 07:55 AM
it should still fix some issue I'd catch MySQLdb error in this init file of registration backend, since it is first to cause problems : import MySQLdb code :
(...)
new_user = None
try:
new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)
except MySQLdb.IntegrityError:
pass
|
Will User.Identity.Name generates the same data as Membership.GetUser().UserName
By : George Ismael
Date : March 29 2020, 07:55 AM
should help you out I'm not sure Generate is the best word. I'm going to assume you meant Return the same data. The answer is not always. code :
@if(Request.IsAuthenticated)
{
<text>Welcome <b>@Context.User.Identity.Name</b>!
[ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text>
}
else
{
@:[ @Html.ActionLink("Log On", "LogOn", "Account") ]
}
|
How to register user by username and password and confirm password and email by membership?
By : Lucas Amoêdo
Date : March 29 2020, 07:55 AM
I wish this help you membership doesn't something like this for you! it is better that you compare your password and confirm password by jquery and then if they were equal, and then use this function : code :
Membership.CreateUser(string username, string password,string mail);
<input id ="password" type="password"/>
<input id ="confirmPassword" type="password"/>
<label class="display" Id="lblerror" >Password not match </label>
<script>
$(document).ready(function () {
$("#confirmPassword").change(function () {
if ($("#password").val() == $("#confirmPassword").val()) {
$("#lblerror").addClass("show");
}
else {
$("#lblerror").removeClass("show");
}
});
});
</script>
.show{
display:none;
|
Allow user to log in with either Email OR UserName (AspNet.Identity)
By : Belen Aranda
Date : March 29 2020, 07:55 AM
like below fixes the issue There will be one security issue. You can get the username of another user if you know his email: write his email and wrong password then the system loads the corresponding user name, performs password validation which fails and returns the model with overwritten username code :
var userName = model.UserName;
using (var context = new ApplicationDbContext())
{
var user = context.Users.FirstOrDefault(p => p.Email == model.UserName);
if (user != null)
{
userName = user.UserName;
}
}
var result = await SignInManager.PasswordSignInAsync(userName, model.Password, model.RememberMe, shouldLockout: true);
|
How to get user attributes (username, email, etc.) using cognito identity id
By : Anna
Date : March 29 2020, 07:55 AM
Hope that helps The ID Token that you exchange with Cognito federated identity service to get the identity id and credentials already has all user attributes. You do not need an extra call to any service. It is a JWT token and you can use any library on the client to decode the values. You can read this guide for more information about the tokens vended by Cognito user pools.
|