All Projects → florent37 → EasyFirebase

florent37 / EasyFirebase

Licence: Apache-2.0 license
No description or website provided.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to EasyFirebase

auth-flow-react-apollo-saga
Full stack login/register flow with React, Apollo, Redux, Redux-saga and MongoDB.
Stars: ✭ 22 (-54.17%)
Mutual labels:  login, auth
Kratos Selfservice Ui React Native
A reference implementation of an app using ORY Kratos for auth (login), sign up (registration), profile settings (update password), MFA/2FA, account recovery (password reset), and more for React Native. This repository is available as an expo template!
Stars: ✭ 24 (-50%)
Mutual labels:  login, auth
laravel-magiclink
Create link for authenticate in Laravel without password or get private content
Stars: ✭ 135 (+181.25%)
Mutual labels:  login, auth
lua-resty-feishu-auth
适用于 OpenResty / ngx_lua 的基于飞书组织架构的登录认证
Stars: ✭ 28 (-41.67%)
Mutual labels:  login, auth
rocket auth
An implementation for an authentication API for Rocket applications.
Stars: ✭ 65 (+35.42%)
Mutual labels:  login, auth
react-apple-signin-auth
 Apple signin for React using the official Apple JS SDK
Stars: ✭ 58 (+20.83%)
Mutual labels:  login, auth
Fastify Esso
The easiest authentication plugin for Fastify, with built-in support for Single sign-on
Stars: ✭ 20 (-58.33%)
Mutual labels:  login, auth
supabase-ui-svelte
Supabase authentication UI for Svelte
Stars: ✭ 83 (+72.92%)
Mutual labels:  login, auth
Django Rest Registration
User-related REST API based on the awesome Django REST Framework
Stars: ✭ 240 (+400%)
Mutual labels:  login, auth
Laravel Adminless Ldap Auth
Authenticate users in Laravel against an adminless LDAP server
Stars: ✭ 199 (+314.58%)
Mutual labels:  login, auth
Php Auth
Authentication for PHP. Simple, lightweight and secure.
Stars: ✭ 713 (+1385.42%)
Mutual labels:  login, auth
hapi-doorkeeper
User authentication for web servers
Stars: ✭ 14 (-70.83%)
Mutual labels:  login, auth
Flask simplelogin
Simple Login - Login Extension for Flask - maintainer @cuducos
Stars: ✭ 133 (+177.08%)
Mutual labels:  login, auth
identifo
Universal authentication framework for web, created with go
Stars: ✭ 58 (+20.83%)
Mutual labels:  login, auth
authorize-me
Authorization with social networks
Stars: ✭ 44 (-8.33%)
Mutual labels:  login, auth
react-signin-form
Concept for Sign in / Sign Up form
Stars: ✭ 109 (+127.08%)
Mutual labels:  login
LoginForKotlin
Kotlin Login demo
Stars: ✭ 37 (-22.92%)
Mutual labels:  login
dart-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Dart/Flutter
Stars: ✭ 30 (-37.5%)
Mutual labels:  auth
YHThirdManager
一个快速、简单、易集成、扩展性好的社交化组件。摒弃友盟等三方库,使用原生SDK。支持微信支付、微信分享、微信登录、微信授权、QQ授权、QQ分享、QQ登录、新浪授权、新浪登录、新浪分享、微博评论、微博获取、支付宝支付。极大的减小了包体积;同时加入了自动管理提示框的功能
Stars: ✭ 41 (-14.58%)
Mutual labels:  login
k8s-pixy-auth
k8s plugin to authenticate against an OIDC compatible issuer using PKCE (pixy) flow
Stars: ✭ 24 (-50%)
Mutual labels:  auth

EasyFirebase

compile 'com.github.florent37:easyfirebase:1.0.0'
Android app on Google Play

Google Login

Initialize

private EasyFirebaseAuth easyFirebaseAuth;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        GoogleApiClient googleApiClient= ...

        this.easyFirebaseAuth = new EasyFirebaseAuth(googleApiClient);
}

@Override
public void onStart() {
    super.onStart();
    easyFirebaseAuth.onStart();
}

@Override
public void onStop() {
    easyFirebaseAuth.onStop();
    super.onStop();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    easyFirebaseAuth.onActivityResult(requestCode, data);
}

Start Login

easyFirebaseAuth.signInWithGoogle((Activity)this)
                .subscribeOn(Schedulers.io())
                .observeOn(Schedulers.io())
                .subscribe(Pair<googleSignInAccount, firebaseUser> -> {
                    //user is connected
                    final String id = firebaseUser.getUid();
                    final String name = firebaseUser.getDisplayName();
                    final String email = firebaseUser.getEmail();
                    final String photoUrl = firebaseUser.getPhotoUrl().toString();
                    //update your UI
                });

Database

Initialize

DatabaseReference database = FirebaseDatabase.getInstance().getReference();

EasyFirebaseDb userDb = new EasyFirebaseDb(database.child("users"), converter);

Create

userDb.addNew(name)
      .withValue("registerDate", System.currentTimeMillis())
      .withValue("id", id)
      .withValue("name", name)
      .withValue("email", email)
      .withValue("photoUrl", photoUrl)
      .push()
      .subscribe(v -> {
            //the user has been created
      })

Query

Observable<User> = userDb.getObject(userName, User.class);

Observable<List<User>> = userDb.getChildsObjects(User.class).toList();

Join

Observable<List<User>> = Observable.zip(
        userDb.getChildsObjects(User.class).toList(),
        followersDb.getKeys(username), //only retrieve the keys
        (users, followers) -> {
             for (User user : users) {
                 final String userName = user.getName();
                 if (followers.contains(userName)) {
                     user.setFollower(true);
                 }
             }
             return users;
});

Converter

public class MyConverterImpl implements RxFirebaseConverter {

    @Override
    public <T> void convert(DataSnapshot dataSnapshot, Class<? super T> theClass, Subscriber<? super T> subscriber){
            if(User.class.equals(theClass)){
                userFromDataSnapshot(dataSnapshot, subscriber);
            } else {
                throw new UnsupportedOperationException("unknown :" + theClass.getCanonicalName().toString());
            }
    }

    public <T> void userFromDataSnapshot(DataSnapshot dataSnapshot, Subscriber<? super T> subscriber) {
            final String userName = dataSnapshot.getKey();
            final String email = dataSnapshot.child("email").getValue(String.class);
            final String id = dataSnapshot.child("id").getValue(String.class);
            final String photoUrl = dataSnapshot.child("photoUrl").getValue(String.class);

            final User user = new User(userName, email, id, photoUrl);

            subscriber.onNext((T)user);
    }

#Credits

Author: Florent Champigny

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2016 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].