Git Product home page Git Product logo

ng2-meteor-accounts's Introduction

Meteor Accounts API for Angular 2.

Accounts services to be used in custom Angular 2 components.

Wraps over API of different Meteor accounts packages, including "accounts-base", "accounts-password", "accounts-facebook" etc.

Additionally, implements some login specific annotations for a convenience of API users.

API

AccountsService

Exposes and combines API of the "accounts-base" and "accounts-password" packages.

Makes API more compatible with the Angular 2 code style, e.g., by making methods return promises.

login(usernameOrEmail: string, password: string): Promise<any>

Simple username/password login.

register(newUser: AccountDetails): Promise<any>

Registers a new account. AccountDetails has a format as follows:

{
  username: string;
  email: string;
  password: string;
  profile?: Object;
}

For more info, please read here.

forgotPassword(email: string):Promise<any>

Sends out a token to reset current password.

resetPassword(token: string, newPassword: string): Promise<any>

Sets a new password with the token provided forgotPassword.

changePassword(oldPassword: string, newPassword: string): Promise<any>

Simply change current password, given the current password and a new one.

verifyEmail(token: string): Promise<any>

Verifies a user email, passed in the register method during the account registration.

AccountsSocialService

Social services login.

loginWith(provider: string, loginOptions?: LoginOptions): Promise<any>

Login with the help of a particular account provider. Among them are Google, Facebook, Twitter, Github, Meteor etc.

To make a particular account provider available, you will need to install a corresponding package, for example:

meteor add accounts-facebook

if you want to allow logining with Facebook.

Original doc can be found here.

loginOptions is used to provide with the following info:

{
  requestPermissions?: Array<string>;
  loginStyle: string;
}

Annotations

@InjectUser(propName: string)

Injects Meteor's user as a property to a Angular 2 component or directive. Available in the component templates as well.

By default, property called user.

Note that new property will be reactive only if you add urigo:angular2-meteor package.

If you want to change property name, pass in a particular name in the annotation.

Internally implementation bases on wrapping of Meteor.user().

@RequireUser()

If placed above a component, will prohibit anonymous access to that component. Only logged-in users (via any ways described above) will be able to load it.

Examples

Services Usage

Imports one of the services and use it in a component as follows:

...

import {AccountsService} from 'meteor-accounts';

@Component({
  selector: 'foo',
  viewProviders: [AccountsService]
})
@View({
  template: '...'
})
class FooAccounts {
  constructor(private accounts: AccountsService) {}

  onLoginBtnClick(email, pwd) {
    this.accounts.login(email, pwd).then(() => alert('logged in'));
  }
}

Annotations Usage

import {InjectUser} from 'meteor-accounts';

@Component({
  selector: 'foo'
})
@View({
  template: '...'
})
@InjectUser('currentUser')
class FooAccounts {
  constructor() {
    // Logs out the current value of Meteor.user(),
    // property is reactive if urigo:angular2-meteor added,
    // can be used in templates as well.
    console.log(this.currentUser);
  }
}

ng2-meteor-accounts's People

Contributors

barbatus avatar

Stargazers

Moemen Elzeiny avatar  avatar amir avatar Mike Grigoriev avatar Andrey Kartashov avatar  avatar Radoslav Kirilov avatar Fabio Dias Rollo avatar billy westbury avatar Jan Słowik avatar Hongbo Miao avatar  avatar Thomas Sattlecker avatar

Watchers

James Cloos avatar Ramin Baradari avatar  avatar  avatar Jin Gyu Chong avatar Thomas Cassou avatar Matthew Wheatley avatar  avatar

ng2-meteor-accounts's Issues

Registre with an email

Hello,

We can't register with email with this package...forgot in account details class.

Thank you.

Just updated meteor: Server error

/myMeteorProjects/netDB/.meteor/local/build/programs/server/packages/barbatus_ng2-meteor-accounts.js:51
W20160113-14:05:55.271(-3)? (STDERR)             class BasicAccountsService {                                      
W20160113-14:05:55.272(-3)? (STDERR)             ^^^^^
W20160113-14:05:55.275(-3)? (STDERR) SyntaxError: Unexpected reserved word

1.3 + npm compatible ?

is ng2-meteor-accounts and ng2-meteor-accounts-ui npm compatible with meteor 1.3-rc.4+?

(I just tried and its not working on my site - because its installing athmosphere packages)

For now i will remove those packages from my current project code and try getting a workaround.

Change types to interfaces

Interfaces in TypeScript can be extended upon, whereas types can't.

/* type AccountDetails = { */
interface AccountDetails {
    ...
}

/* type loginOptions =  { */
interface LoginOptions {
   ...
}

This will allow the User type to be extended in the Angular2 tutorial:

/typings/party.d.ts

interface User extends ngMeteorAccounts.AccountDetails {
  invited: boolean;
}

Cant use InjectUser and RequireUser decorators

when I try to build the application using one of the decoratores i get this error:

Unexpected token < Evaluating http://localhost:3000/angular2/src/core/util/decorators Error loading http://localhost:3000/client/app

tried to reset and reinstall all packages, no luck.

Any plans to update this project for newer angular2 conventions?

I've tried to get this to work in a project that's using angular2-rc0 -- the main problem I'm having is that it seems typings are bundled in this module and pollute the project space.

Do you have plans to update this package a newer angular2 (and drop the typings in the package)?

Example:

> Started proxy.
=> Started MongoDB.
***** Typings that have been added/updated *****
typings/angular2/angular2.d.ts
typings/angular2/common.d.ts
typings/angular2/core.d.ts
typings/angular2/http.d.ts
typings/angular2/router.d.ts
typings/angular2/platform/browser.d.ts
imports/ui/administration/organization/create/create-organization.component.ts (12, 33): Cannot find module 'angular2-meteor'.
imports/ui/administration/organization/create/create-organization.component.ts (13, 46): Cannot find module '@angular/core'.
imports/ui/administration/organization/create/create-organization.component.ts (14, 55): Cannot find module '@angular/common'.
imports/ui/administration/organization/create/create-organization.component.ts (22, 28): Cannot find module '../../../../thirdparty/ng2-meteor-accounts/annotations.ts'.
imports/ui/administration/organization/create/create-organization.component.ts (24, 24): Cannot find module '@angular/router-deprecated'.
imports/ui/administration/organization/create/create-organization.component.ts (73, 10): Property 'subscribe' does not exist on type 'OrganizationCreateFormComponent'.
imports/ui/administration/organization/edit/edit-organization.component.ts (12, 77): Cannot find module '@angular/core'.
imports/ui/administration/organization/edit/edit-organization.component.ts (14, 33): Cannot find module 'angular2-meteor'.
imports/ui/administration/organization/edit/edit-organization.component.ts (18, 28): Cannot find module '../../../../thirdparty/ng2-meteor-accounts/annotations.ts'.
imports/ui/administration/organization/edit/edit-organization.component.ts (19, 37): Cannot find module '@angular/router-deprecated'.
imports/ui/administration/organization/edit/edit-organization.component.ts (123, 10): Property 'subscribe' does not exist on type 'OrganizationEditFormComponent'.
imports/ui/administration/organization/edit/edit-organization.component.ts (126, 32): Property 'subscribe' does not exist on type 'OrganizationEditFormComponent'.
imports/ui/test-case-library/test-case-view/test-case-property/test-case-property.component.ts (12, 72): Cannot find module '@angular/core'.
imports/ui/test-case-library/test-case-view/test-case-property/test-case-property.component.ts (13, 33): Cannot find module 'angular2-meteor'.
imports/api/test-case/execution-status/execution-status.service.ts (11, 28): Cannot find module '@angular/core'.
imports/api/test-case/priority/priority.service.ts (11, 28): Cannot find module '@angular/core'.
imports/api/test-case/status/status.service.ts (11, 28): Cannot find module '@angular/core'.

RequireUser no longed extends CanActivate

As far as I can find out right now this causes the router to ignore the RequireUser annotation as it's looking for instances of CanActivate objects. Will try and test this tomorrow unless you find the time to check it before that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.