本文整理汇总了Java中com.firebase.client.Firebase.authWithPassword方法的典型用法代码示例。如果您正苦于以下问题:Java Firebase.authWithPassword方法的具体用法?Java Firebase.authWithPassword怎么用?Java Firebase.authWithPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.client.Firebase
的用法示例。
在下文中一共展示了Firebase.authWithPassword方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
public void login(String username, String password) {
final Firebase myFirebaseRef = RegLog.getFirebase();
myFirebaseRef.authWithPassword(username, password, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("Successfully authenticated with uid: " + authData.getUid());
EventBus.getDefault().post(new LoginCallbackEvent(true, null));
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
EventBus.getDefault().post(new LoginCallbackEvent(false, firebaseError.getMessage()));
}
});
}
示例2: settingFirebase
import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
* ***************************************************************************
*/
private Firebase settingFirebase(String urlFirebase, String child) {
Firebase firebase = new Firebase(urlFirebase).child(child);
firebase.authWithPassword(mUsernameMail, mUsernamePwd, new AuthResultHandler("password"));
mAuthStateListener = new Firebase.AuthStateListener() {
@Override
public void onAuthStateChanged(AuthData authData) {
setAuthenticatedUser(authData);
}
};
firebase.addAuthStateListener(mAuthStateListener);
firebase.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
mAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
return firebase;
}
示例3: registerComponents
import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override public void registerComponents(Context context, Glide glide) {
Firebase fb = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
fb.authWithPassword("", "", null); // TODO fire auth to background if needed, see FirebaseImageModelLoader ctor
glide.register(FirebaseImage.class, InputStream.class, new FirebaseModelLoader.Factory(fb));
}
示例4: login
import com.firebase.client.Firebase; //导入方法依赖的package包/类
public void login (View view) {
String email = mUserLoginEmail.getText ().toString ();
String password = mUserLoginPassword.getText ().toString ();
if (Utils.isEmpty (email)) {
mUserLoginEmail.setError ("This field is required");
} else if (Utils.isEmpty (password)) {
mUserLoginPassword.setError ("This field is required");
} else if (Utils.isNotEmpty (email) && Utils.isNotEmpty (password)) {
if (Utils.isOnLine (LoginActivity.this)) {
mProgress = ProgressDialog.show (LoginActivity.this, "", getString (R.string.loading), true, false);
ref = new Firebase (Constants.FIREBASE_URL_USERS);
ref.authWithPassword (email, password, new Firebase.AuthResultHandler () {
@Override
public void onAuthenticated (AuthData authData) {
if (mProgress != null)
mProgress.dismiss ();
startActivity (new Intent (LoginActivity.this, ViewPageActivity.class));
}
@Override
public void onAuthenticationError (FirebaseError firebaseError) {
if (mProgress != null)
mProgress.dismiss ();
switch (firebaseError.getCode ()) {
case FirebaseError.USER_DOES_NOT_EXIST:
// handle a non existing user
Toast.makeText (LoginActivity.this, "User does not exist", Toast.LENGTH_SHORT).show ();
break;
case FirebaseError.INVALID_PASSWORD:
// handle an invalid password
Toast.makeText (LoginActivity.this, "Password is incorrect", Toast.LENGTH_SHORT).show ();
break;
default:
// handle other errors
break;
}
}
});
SharedPreferences.Editor editor = pref.edit ();
editor.clear ();
editor.commit ();
} else {
Utils.showLongMessage (Constants.CHECK_CONNECTION, LoginActivity.this);
}
}
}
示例5: attemptLogin
import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void attemptLogin() {
// Reset errors.
mEmailView.setError(null);
mPasswordView.setError(null);
// Store values at the time of the login attempt.
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
// Check for a valid password, if the user entered one.
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
mPasswordView.setError(getString(R.string.error_invalid_password));
focusView = mPasswordView;
cancel = true;
}
// Check for a valid email address.
if (TextUtils.isEmpty(email)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!isEmailValid(email)) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
} else {
showProgress(true);
Firebase ref = new Firebase(Constant_ApplicationConstant.FirebaseURL);
Firebase.AuthResultHandler authResultHandler = new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
Log.e("AuthData", authData.toString());
SharedPreferences.Editor ed = sp.edit();
ed.remove("UID");
ed.putString("UID", authData.getUid());
ed.commit();
showProgress(false);
goToUserList(authData.getUid());
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
Log.e("AuthErr", firebaseError.toString());
Toast.makeText(getBaseContext(),firebaseError.toString(),Toast.LENGTH_SHORT).show();
showProgress(false);
}
};
ref.authWithPassword(email,password,authResultHandler);
}
}