Merge pull request #21 from Qtoss-AI/hdongDev
hdong: When use verify fail, they need to re-register again.
This commit is contained in:
commit
76a30c4fdd
|
|
@ -27,6 +27,7 @@ public interface IBotSharpRepository
|
|||
User? GetUserByAffiliateId(string affiliateId) => throw new NotImplementedException();
|
||||
User? GetUserByUserName(string userName) => throw new NotImplementedException();
|
||||
void CreateUser(User user) => throw new NotImplementedException();
|
||||
void UpdateExistUser(string userId, User user) => throw new NotImplementedException();
|
||||
void UpdateUserVerified(string userId) => throw new NotImplementedException();
|
||||
void UpdateUserVerificationCode(string userId, string verficationCode) => throw new NotImplementedException();
|
||||
void UpdateUserPassword(string userId, string password) => throw new NotImplementedException();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class UserService : IUserService
|
|||
|
||||
public async Task<User> CreateUser(User user)
|
||||
{
|
||||
string hasRegisterId = null;
|
||||
if (string.IsNullOrEmpty(user.UserName))
|
||||
{
|
||||
// generate unique name
|
||||
|
|
@ -48,7 +49,7 @@ public class UserService : IUserService
|
|||
|
||||
if (record != null)
|
||||
{
|
||||
return record;
|
||||
hasRegisterId = record.Id;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(user.Id))
|
||||
|
|
@ -71,7 +72,14 @@ public class UserService : IUserService
|
|||
record.Verified = false;
|
||||
}
|
||||
|
||||
db.CreateUser(record);
|
||||
if (hasRegisterId == null)
|
||||
{
|
||||
db.CreateUser(record);
|
||||
}
|
||||
else
|
||||
{
|
||||
db.UpdateExistUser(hasRegisterId, record);
|
||||
}
|
||||
|
||||
_logger.LogWarning($"Created new user account: {record.Id} {record.UserName}");
|
||||
Utilities.ClearCache();
|
||||
|
|
@ -386,8 +394,9 @@ public class UserService : IUserService
|
|||
}
|
||||
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
|
||||
var user = db.GetUserByUserName(userName);
|
||||
if (user != null)
|
||||
if (user != null && user.Verified)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -404,7 +413,7 @@ public class UserService : IUserService
|
|||
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
var emailName = db.GetUserByEmail(email);
|
||||
if (emailName != null)
|
||||
if (emailName != null && emailName.Verified)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,18 @@ public partial class MongoRepository
|
|||
_dc.Users.InsertOne(userCollection);
|
||||
}
|
||||
|
||||
public void UpdateExistUser(string userId, User user)
|
||||
{
|
||||
var filter = Builders<UserDocument>.Filter.Eq(x => x.Id, userId);
|
||||
var update = Builders<UserDocument>.Update
|
||||
.Set(x => x.Email, user.Email)
|
||||
.Set(x => x.Phone, user.Phone)
|
||||
.Set(x => x.Salt, user.Salt)
|
||||
.Set(x => x.Password, user.Password)
|
||||
.Set(x => x.VerificationCode, user.VerificationCode);
|
||||
_dc.Users.UpdateOne(filter, update);
|
||||
}
|
||||
|
||||
public void UpdateUserVerified(string userId)
|
||||
{
|
||||
var filter = Builders<UserDocument>.Filter.Eq(x => x.Id, userId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue