// Username is already in use by a different account.
return"","",status.Error(codes.AlreadyExists,"Username is already in use.")
iferr==sql.ErrNoRows{
found=false
}else{
logger.Error("Cannot find user with custom ID.",zap.Error(err),zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Internal,"Error finding user account.")
}
logger.Error("Cannot find or create user with custom ID.",zap.Error(err),zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Internal,"Error finding or creating user account.")
}
// Existing account found.
iffound{
// Check if it's disabled.
ifdbDisableTime!=0{
logger.Debug("User account is disabled.",zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Unauthenticated,"Error finding or creating user account.")
// No user account found, and creation is not allowed.
return"","",status.Error(codes.NotFound,"User account not found.")
}else{
logger.Error("Cannot find user with custom ID.",zap.Error(err),zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Internal,"Error finding user account.")
}
}
ifdbDisableTime!=0{
logger.Debug("User account is disabled.",zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Unauthenticated,"Error finding or creating user account.")
// A concurrent write has inserted this custom ID.
return"","",status.Error(codes.Internal,"Error finding or creating user account.")
}
}
logger.Error("Cannot find or create user with custom ID.",zap.Error(err),zap.String("customID",customID),zap.String("username",username),zap.Bool("create",create))
return"","",status.Error(codes.Internal,"Error finding or creating user account.")