Flutter webview need to autofill the values form app session in the username and email fields. I am not able achieve it using flutter webivew. I tried with flutter InAppWebView but unable to achieve it is there any to make it work with flutter webview.
It means you are not really storing the values to your session. Use user sessions instead. Check out Consession. The package adds user session support in Flutter and is easy to use.
// Store value to session
await Consession().set("user", jsonencode(user));
// Retrieve item from session
dynamic user = await Consession().get("user");
controller.evaluateJavascript(
//'''var email = document.getElementById("user");''';
source: '''
var email = document.getElementById(" Your Email document id from html");
var password = document.getElementById("Your Email document id from html");
email.value = "$email";
password.value = "$pass";
document.getElementById('password id from html page').click();
''');
Use above code to autofill using javascript by getting ids of html webpage using page inspection,The code should be used after webpage finishes loading
Related
I am creating an app (Xcode, swift) that has a profile page for each user and I want their name to appear on that page.
I have been able to get their email address through:
let email : String = (Auth.auth().currentUser?.email)!
How would I gather the users name? I have the users UID as well.
I am using firebase by the way
If you are not using Google or Facebook to log in with firebase, You need to manually create the profile for each user. See Update a user's profile
If you're using a social provider to sign in, you can get the display name from that provider through Firebase with:
Auth.auth().currentUser?.displayName
If you're signing in with another provider, the display name won't automatically be set, and you will (as Abdullah answered) have to create your own registration system where the user enters their name - and you then store it in the displayName property of Firebase Authentication.
To achieve what you requested, you either have to use a social auth provider (such as Google or Facebook) or change it yourself from the client, as the other answers suggest.
First of all, you would have to create a changeRequest, using the following code
let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
Once the change request is created, you can change whatever basic information you need to (either the photo URL or the display name) with the following code:
changeRequest?.displayName = "Lorem ipsum"
changeRequest?.photoURL = "https://your_link/path_to_image.png"
Finally, you must send the change request to Firebase, which will handle it and possibly return an error for you to handle.
changeRequest?.commitChanges { error in
if let error = error {
print(error.localizedDescription)
// You can handle the given error here
return
}
}
As others have already pointed out, you can find this and more information on the official on the official Firebase docs website.
I want to use the Firestore database to save some input data from Google Chrome Extension (i.e., the user email). I am also using Firebase Authentication which works as expected (i.e., the user is able to login successfully). I am now trying to save the email of the user in the database. However, the code below is not working.
Here is the code (please note that I am not actually saving the email of the user and this is just testing whether the email is being saved in the database):
var firebaseConfig = {
...
databaseURL: "project.firebaseio.com",
...
}
firebase.initializeApp(firebaseConfig);
var db = firebase.database();
db.collection("users").doc("test").set({
email: "some-email#email.com"
});
Also in the .html page, I have
<script src="https://www.gstatic.com...-firestore.js"></script>
In case you need to inject Firebase Web Javascript Module version 9+ inside an webpage, here is a gist with an example:
https://gist.github.com/cheadrian/d3a6604c0f680980cd232a89a1719153
Basically you need to refer a Javascript inside "content_scripts" in manifest.json witch will add the Firebase code before close of the <body> tag.
I'm writing a simple application in Xamarin.Forms that allows users the authentication through socials such as Facebook, Google, Instagram, Twitter, etc. I'm using Xamarin.auth to do this. I have a problem with Facebook Login. I used the same code reported in the official guide:
https://components.xamarin.com/gettingstarted/xamarin.auth
But after the application has requested the user for credentials, the response (in the code, t.Result.GetResponseText(), section 3) is a json contains the Facebook user name and surname, and a field called "id". Instead, I need all profile informations of the user, such as age, gender, etc. I suppose that I have to use the id returned for build an http request to a facebook service for retrieve data from the id.
You need to specify in your facebook link the requiered fields.
Example:
var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=email,first_name,last_name,gender,picture"), null, eventArgs.Account);
After how I Get the fields
var response = await request.GetResponseAsync();
var obj = JObject.Parse(response.GetResponseText());
var id = obj["id"].ToString().Replace("\"", "");
var name = obj["first_name"].ToString().Replace("\"", "");
var lastName = obj["last_name"].ToString().Replace("\"", "");
var email = obj["email"].ToString().Replace("\"", "");
'm using the Facebook SDK 6.0 for Unity3D.
After my user accept the connection, I want to save his ID, email etc ... on a Parse database, and have the possibility to get some info from this database for this player (for exemple : the list of unlock levels).
How can I do it ?
I know how create an object, but I want to know, after a connection on Facebook, how to save the user and some details on Parse, without using the Parse login (as on the official Parse tutorial).
I can't understand.
Thank you very very much in advance for your help.
Best regards,
AB
You can try saving this information in the local ParseUser Object. Just add custom fields with the necessary information. For more complex solutions you can create a custom parse object to save the information.
https://parse.com/docs/unity_guide#users
var user = new ParseUser()
{
Username = "my name",
Password = "my pass",
Email = "email#example.com"
};
// other fields can be set just like with ParseObject
user["IsUnlocked"] = true;
Task signUpTask = user.SignUpAsync();
and for Facebook there is a special signup method in the ParseFacebookUtils class
https://parse.com/docs/unity_guide#fbusers
Task<ParseUser> logInTask = ParseFacebookUtils.LogInAsync(userId, accessToken, tokenExpiration);
In my meteor app, I'm setting up the registration process.
Meteor has a Account.sendVerificationEmail method to send emails out to new users with a token to verify their email address
My app does need this functionality but I don't really want to use the sendVerificationEmail to send the emails because I already have my own email helper which has got a bunch of logic and I want all the emails in my system to pass to flow out of that function.
So my question is that I do want to create my verification token for the user on registration, but I don't want sendVerificationEmail to send an email out because I want to do it manually.
Is this possible?
First add the core "random" package for random code generation
$ meteor add random
Then intercept the account creation process
Accounts.onCreateUser(function(options, user) {
// create a verified flag and set it false
user.customVerified = false;
//20 character random lowercase hex string. You can use a hash of some user info if you like. I just put this here for demonstration of the concept :)
user.customVerificationCode = Random.hexString(20).toLowerCase();
//pass the new user's email and the verification code to your custom email function so that you can craft and send the mail. Please double check the option.profile.emails[0], the email should be available somewhere within the options object
myCustomEmailFunction(options.profile.emails[0], user.customVerificationCode);
// continue with account creation
return user;
});
At this point, if you don't want to show pieces of ui elements to unverified users, you can create a template helper for that. Or you can check if user is verified in your publications. Etc... whatever you want to restrict.
Now you can define a route in your app with iron router so that when the user clicks on the link, the route takes the verification code and set's the user's verified flag to true.
You can fake the verification record for the user in the MongoDB document and then send your own email:
//Fake the verificationToken by creating our own token
var token = Random.secret();
var tokenRecord = {
token: token,
address: Meteor.user().emails[0].address,
when: new Date(),
};
//Save the user
Meteor.users.update(
{_id: Meteor.userId()},
{$push: {'services.email.verificationTokens': tokenRecord}}
, function(err){
//Send an email containing this URL
var confirmUrl = Meteor.absoluteUrl() + '#/verify-email/' + token;
//Send using SendGrid, Mandrill, MailGun etc
});
Code taken from GitHub:
https://github.com/meteor/meteor/blob/5931bcdae362e1026ceb8a08e5a4b053ce5340b7/packages/accounts-password/password_server.js