UNPKG

ionic-coreo

Version:

Ionic2 module for integration with Coreo

130 lines 5.23 kB
"use strict"; var core_1 = require('@angular/core'); var login_component_template_1 = require('./login.component.template'); var auth_1 = require('../../auth'); var user_1 = require('../../user'); var config_1 = require('../../config'); var ionic_angular_1 = require('ionic-angular'); var signup_component_1 = require('./signup/signup.component'); var email_login_component_1 = require('./email-login/email-login.component'); var username_confirmation_component_1 = require('./username-confirmation/username-confirmation.component'); var CoreoLoginComponent = (function () { function CoreoLoginComponent(auth, config, user, alertCtrl, navCtrl, viewCtrl, navParams, app) { this.auth = auth; this.config = config; this.user = user; this.alertCtrl = alertCtrl; this.navCtrl = navCtrl; this.viewCtrl = viewCtrl; this.navParams = navParams; this.app = app; this.isLoggingIn = false; this.isSigningUp = false; this.loginError = false; this.signupError = false; this.usernameError = false; this._allowSignup = true; this.login = new core_1.EventEmitter(); this.imageUrl = this.navParams.get('imageUrl'); } Object.defineProperty(CoreoLoginComponent.prototype, "allowSignup", { get: function () { return this._allowSignup; }, set: function (value) { if (value === null || value === undefined || typeof value === "boolean") this._allowSignup = value; else this._allowSignup = value.toString() === "true"; }, enumerable: true, configurable: true }); CoreoLoginComponent.prototype.oauth = function (method, options) { var _this = this; this.isLoggingIn = true; return this.auth.login(method, options).then(function (res) { if (!_this.user.usernameConfirmed) { _this.navCtrl.push(username_confirmation_component_1.CoreoUsernameConfirmationComponent, { username: _this.user.username, onSuccess: function () { _this.viewCtrl.dismiss(true); } }); } else { _this.viewCtrl.dismiss(true); } }, function (err) { if (!(err && err.startsWith && err.startsWith('The user cancel'))) { _this.alertCtrl.create({ title: 'Login Error', message: err, buttons: [{ text: 'OK', role: 'cancel' }] }).present(); } _this.isLoggingIn = false; }); }; CoreoLoginComponent.prototype.google = function (event) { var _a = this.config, surveyId = _a.surveyId, googleWebClientId = _a.googleWebClientId; return this.oauth('google', { webClientId: googleWebClientId, surveyId: surveyId }); }; CoreoLoginComponent.prototype.facebook = function (event) { var surveyId = this.config.surveyId; return this.oauth('facebook', { surveyId: surveyId }); }; CoreoLoginComponent.prototype.email = function (event) { var _this = this; event.preventDefault(); event.stopImmediatePropagation(); this.navCtrl.push(email_login_component_1.CoreoEmailLoginComponent, { onSuccess: function () { _this.viewCtrl.dismiss(true); } }); }; CoreoLoginComponent.prototype.coreoInfo = function () { window.open(this.config.publicUrl + '/about'); }; CoreoLoginComponent.prototype.close = function () { this.viewCtrl.dismiss(false); }; CoreoLoginComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'coreo-login', template: login_component_template_1.DEFAULT_TEMPLATE, styles: [login_component_template_1.DEFAULT_STYLES, login_component_template_1.SHARED_STYLES], entryComponents: [ signup_component_1.CoreoSignupComponent, email_login_component_1.CoreoEmailLoginComponent ] },] }, ]; /** @nocollapse */ CoreoLoginComponent.ctorParameters = function () { return [ { type: auth_1.CoreoAuth, }, { type: config_1.CoreoConfig, }, { type: user_1.CoreoUser, }, { type: ionic_angular_1.AlertController, }, { type: ionic_angular_1.NavController, }, { type: ionic_angular_1.ViewController, }, { type: ionic_angular_1.NavParams, }, { type: ionic_angular_1.App, }, ]; }; CoreoLoginComponent.propDecorators = { 'imageUrl': [{ type: core_1.Input },], 'coreoLogoUrl': [{ type: core_1.Input },], 'allowSignup': [{ type: core_1.Input },], 'login': [{ type: core_1.Output },], }; return CoreoLoginComponent; }()); exports.CoreoLoginComponent = CoreoLoginComponent; //# sourceMappingURL=login.component.js.map