How to get the email address from user roles in AppMaker? I understand that app.user.role return a boolean whether the email address was assigned to that role or not. But how do we get the role email address then?
Server API has app.getRoleMemebers() which is what you want:
var role = app.roles.Admins;
var members = app.getRoleMembers(role);
Related
At the moment this is a general question with no code as I am looking for a BEST practices example to my question:
User issues an email change request. (done)
A link is sent to the new address to confirm the new email. (done)
User clicks the confirmation link and the DB update is complete. (done)
What also needs to happen is when the confirmation link is sent for the change, an email should also be sent to the original email address where the user can click a link to reverse the process for whatever reason. I would think also that even if the new email address was accepted, if the original link denies the change it reverts and 2) if the original email reverts and then the new email link is confirmed, that the request would then be denied.
Any direction or code on this matter would be greatly appreciated.
Seems like a simple bit field in the database user record would suffice, or an associated database record would work too. When both emails are sent, mark the field for that user, let's call it "ChangeEmailSent" to 1. When either email is clicked, the field should be updated to 0. The actual changing of the email should only occur if the field is 1.
Some pseudo-code if you like
private void CancelEmailChange(email)
{
var user = Database.GetUser(email);
user.ChangeEmailSent = false;
Database.Save();
}
private void ProcessEmailChange(email)
{
var user = Database.GetUser(email);
if (user.ChangeEmailSent)
{
user.email = getNewEmailAddress(); //whatever logic for a new email
user.ChangeEmailSent = false;
Database.Save();
}
}
I'm new to Firebase. I was looking at the Firebase documentation and it seems good. But one thing I've noticed is that when I register/sign up my users, I can only get their email ID and password.
However, for my app, I need my users to enter more details like name, address, phone, and some other details. How can I do this?
I thought maybe I can use the real time database, but then I didn't know how to match the users with their respective details from the realtime database. Please give me some ideas on how to do this.
You're right.
In order to save some user data, you will have to use Realtime Database. There are few properties you can assign to user like email, photoURL, displayName but for more than that you have to use database.
Hope it helps, here is a way I am doing it:
I created "users" node in database and every time new user registers, new entry with his uid gets inserted. Check screenshot below:
So every time you need to get user data, just call child at "users" node with given "current user uid".
On Success of registration , get all the details and update/create the information in firebase database.
final String emailId = mEditTextEmail.getText().toString() ;
String password = mEditTextPassword.getText().toString() ;
firebaseRef.createUser(emailId, password, new Firebase.ValueResultHandler<Map<String,Object>>() {
#Override
public void onSuccess(Map<String, Object> stringObjectMap) {
User user = new User();
user.setUid(stringObjectMap.get("uid").toString());
user.setEmail(emailId);
user.setProfileStatus(User.NEW);
firebaseRef.child("Users").child(user.getUid()).setValue(user);
mProgressBar.setVisibility(View.GONE);
Intent intent = new Intent(SignupActivity.this,LoginActivity.class);
intent.putExtra("email",mEditTextEmail.getText().toString());
startActivity(intent);
Toast.makeText(getBaseContext(),"You are Successfully Registered in",Toast.LENGTH_SHORT).show();
Toast.makeText(getBaseContext(),"Login to continue..",Toast.LENGTH_SHORT).show();
}
I need to find out what is my account . I looked at the following tables :
dbc.accounts
DBC.AccountInfoV
DBC.ProfileInfo
They have the accountname, which is not the same . WHere can I find my account ?
Thanks
Your currently active account can be retrieved using the built-in ACCOUNT function:
SELECT ACCOUNT;
Your default account is returned by:
SELECT DefaultAccount
FROM dbc.UsersV
WHERE UserName = USER;
And the list of all accounts your user might use, assigned either to the user directly or via the user's profile:
SELECT AccountName
FROM dbc.accountinfoVX
WHERE (PROFILE IS NULL AND USERNAME = USER)
OR (USERNAME = PROFILE)
I can't figure out why my WebSecurity.ChangePassword is not working. Here's the piece of code I'm working on.
if (WebSecurity.ChangePassword(USER, oldpass, password)) {
Response.Redirect("~/SuperAdmin");
return;
}else {
ModelState.AddFormError(USER);
// I put the each WebSecurity.ChangePassword parameter to this parameter to check whether
//each parameter valid or not (print it out)
}
and for each parameter of WebSecurity.ChangePassword, I retrieve it from the database as follows
if(IsPost){
Validation.RequireField("email", "Masukkan email");
Validation.RequireField("password", "Masukkan Password");
Validation.RequireField("userid", "user ID tidak ada!");
email = Request.Form["email"];
password = Request.Form["password"];
userId = Request.Form["userId"];
if(Validation.IsValid()){
var db = Database.Open("StarterSite");
var updateCommand2 = "UPDATE UserProfile SET Email=#0 WHERE UserId=#1";
db.Execute(updateCommand2, email,userId);
var USER = db.QueryValue("SELECT a.Email FROM UserProfile a, webpages_Membership b WHERE a.UserId=b.UserId AND a.UserId= #0", userId);
var oldpass = db.QueryValue("SELECT Password FROM webpages_Membership WHERE UserId = #0", userId);
Can anyone tell me what seems to be the problem here? Thanks in advance
The WebPages Membership has everything built you do not need to get the users email address and password (I am guessing the email address is the username right?) The ChangePassword method takes 3 arguments. which is UserName, CurrentPassword, NewPassword.
The reason your getting false is because your getting the old password from the database based on the users current Id, but the old password does not match the users current password because old one is encrypted and you're not encrypting the one they submit (in fact you don't even have a field for them to enter their current password).
The WebPages Membership provider will do all the updating you do not need open the database and update the users password, the weird thing you're doing is telling the user to enter a new password but not asking for the current one! Here see this for more information:
http://www.thecodingguys.net/reference/asp/websecurity-changepassword
Make sure the user you are trying to change password for is not LockedOut. You can check it by this
select * from aspnet_membership
where
IsLockedOut = 1
I am using membership api to fetch the user password and email.
I have got this code:
MembershipUser currentUser = Membership.GetUser();
UserPasssword.Text = currentUser.GetPassword(); //Null exception
I need to check the user at the login. The problem is that the user isnt login. So I thought to find a way to fetch the user password or email with the membership api and not through the a database query. Is there a way to do it? or do I have to resort to a database query?
Remember that the user isnt logged in .. .. So the result will be null point exception each time on the currentUser object..
How can check his email with the membership api and then use a redirection:
if (currentUser.Email == LoginEmail.Text && currentUser.GetPassword() == hash)
{
FormsAuthentication.RedirectFromLoginPage(currentUser.UserName, false);
}
else
{
LoginFail.Text = "Email or Password havent been incorrect.";
}
If you're just trying to log the user in, you'd be better off letting membership handle it via the Validate User method.
To get the Email and Password of a user, you can use Membership.GetUser(username). This method returns a MembershipUser object that you can query Email and GetPassword().