npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

firewire-angular-auth

v1.0.9

Published

firewire | a modular ecosystem for building firebase apps in express.

Downloads

11

Readme

get firewire

Use this module with https://www.npmjs.com/package/firewire-angular

Install

Install into your public node_modules folder (if this doesn't make sense, check out https://www.npmjs.com/package/firewire).

$ npm install firewire-angular-auth --save

Firebase

For this module to work - you will need to enable your particular auth method in firebase.

What you get

  • login & i forgot my password views
  • login by
    • email / password
    • anonymous
    • third party provider - facebook / google / github (note that these methods are not all tested)
  • logout
  • password reset
  • password change
  • email change

Coming soon - create / delete users

Add 'login' & 'i forgot my password' views

Within your firewire-angular-auth module you should have 2 jade files. Move these to your views folder.

Now you can set up the following firewire route in index.js

router.get('/user/:page', function(req, res, next) {
    firewire.wire(req,res,firewire.load,[]);
});

Now when you go to localhost:3000/user/login you'll be greeted with a login screen.

Redirecting to your page of choice when logged in

Within node_modules/angular-fire-auth lives controller.js
Just change the route here to redirect to your page of choice.

if(authdata){window.location.assign("/admin/pages");}

Authenticating within your own app

Add the file as a dependancy in your jade template

script(src="/node_modules/firewire-angular-auth/index.js")

Add the auth module as a dependancy in your angular app

You should also have firebase and firewireModule as dependancies.

var app = angular.module('app', [
    "firebase",
    "firewireModule",
    "firewireAuthModule"
]);

Auth module is now set up :)

Doing something on auth / unauth

app.controller('myController',['$rootScope', function ($rootScope) {
	$rootScope.auth.$onAuth(function(authdata){
		// Where should we be redirected on auth?

		if(authdata){window.location.assign("/some/where");}
		else if(!authdata){window.location.assign("/user/login");}
	});
}]);

Methods

firewire-angular-auth exposes $rootScope.auth which contains the firebase auth data and $rootScope.fwUser (which connects to the fwUser service).
$rootScope.auth lets you check auth state and perform actions based on that state.
$rootScope.fwUser lets you perform all your user actions and get your users data.

fwUser.act()

fwUser.act(action, provider, id, password, changeParameter)

action : 'login', 'logout', 'changePassword', 'changeEmail', 'passwordReset'

provider : 'password', 'thirdParty','anon'

provider is needed to tell firebase which type of auth we are using eg. email / password, third party, anonymous, ...

id

id is email when using provider : 'password'. It is either 'google', 'facebook', or 'github' if using provider : 'thirdParty'

password - duh

changeParameter

Used when changing an email or password. This is either the new email or password.

Examples

All of these can be done straight from your UI. If doing them within a controller (etc.) remember to inject $rootScope and call $rootScope.fwUser.act()

login with email / password

fwUser.act('login', 'password', email, password);

Anonymous login (Do this in your js)

Remember to inject $rootScope into your controller, service, etc...

$rootScope.fwUser('login', 'anom');

login thirdParty

fwUser.act('login', 'thirdParty', 'google');

logout

fwUser.act('logout');

password reset

fwUser.act('passwordReset');

change password

fwUser.act('changePassword','password', email, oldPassword, newPassword);

change email

fwUser.act('changeEmail','password', oldEmail, Password, newEmail);

fwUser.get() vs user

If you need to get a user's data you can do either:

app.controller('myController',['$rootScope', function ($rootScope) {
	$rootScope.auth.$onAuth(function(authdata){

		if(authdata){$rootScope.fwUser.get();}

	});
}]);

Or just user $rootScope.user which already does the above.

Either will dip into firebase/users/{id} and return the data object from that node.

Auth states and error messages within your UI

$rootScope.auth contains some useful utilities that you can use straight from the UI.

$rootScope.auth.loginStatus can either be 'loggedIn', 'loggedOut', or 'trying'

Trying is useful for when a user can clicked the login button, and is waiting for a response.

$rootScope.auth.alert - Will = 'authAlert' if there is an issue with auth.

$rootScope.auth.alertMsg - Can be plugged in to display the error message.

Example:

.alert.alert-success(ng-show="auth.loginStatus ==='trying'") logging in...
.alert.alert-danger(ng-show="auth.alert ==='autherror'") {{auth.alertMsg}}

This will show a "logging in" message while the authStatus is neither loggedIn or loggedOut.
Furthermore an error message will be displayed if there is an error.