This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| let firebase = require('firebase-admin'); | |
| let axios = require('axios'); | |
| let serviceAccount = require('./auth.json'); | |
| firebase.initializeApp({ | |
| credential: firebase.credential.cert(serviceAccount), | |
| databaseURL: 'https://react-quick-start.firebaseio.com' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import logo from './logo.svg'; | |
| import './App.css'; | |
| class App extends Component { | |
| render() { | |
| return ( | |
| <div className="App"> | |
| <div className="App-header"> | |
| <img src={logo} className="App-logo" alt="logo" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import firebase from 'firebase'; | |
| import logo from './logo.svg'; | |
| import './App.css'; | |
| class App extends Component { | |
| constructor (props) { | |
| super(props); | |
| this.state = { | |
| users: ['Carregando...'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(N) { | |
| const binN = (N >>> 0).toString(2); | |
| const untrailed = binN.slice(0, binN.lastIndexOf(1) + 1); | |
| return untrailed.split(1) | |
| .filter(x => x.indexOf('0') > -1) | |
| .reduce((val, acc) => val.length > acc.length ? val : acc, '') | |
| .length; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| login(obj) { | |
| this.postRequest('http://localhost:8888/api/student_auth/login', obj).subscribe( | |
| function(result) { console.log('result', result); } | |
| ); | |
| // Não vai funcionar porque o callback acima do subscribe é assíncrono | |
| // return result; | |
| } | |
| postRequest(url, data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ion-content> | |
| <ion-list> | |
| <form [ngFormModel]="loginForm" (submit)="onLogin($event)"> | |
| <ion-item> | |
| <ion-label floating primary>Email</ion-label> | |
| <ion-input ngControl="email" type="text" #email="ngForm" required> | |
| </ion-input> | |
| </ion-item> | |
| <control-messages control="email"></control-messages> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Component, Host} from 'angular2/core'; | |
| import {NgFormModel} from 'angular2/common'; | |
| import {ValidationService} from './validation.service'; | |
| @Component({ | |
| selector: 'control-messages', | |
| inputs: ['controlName: control'], | |
| template: `<p *ngIf="errorMessage !== null">{{errorMessage}}</p>` | |
| }) | |
| export class ControlMessages { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class ValidationService { | |
| static getValidatorErrorMessage(code: string) { | |
| let config = { | |
| 'required': 'Campo obrigatório', | |
| 'invalidEmailAddress': 'Email inválido' | |
| }; | |
| return config[code]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Page} from 'ionic-angular'; | |
| import {FormBuilder, Validators, ControlGroup} from 'angular2/common'; | |
| import {ValidationService} from "./validation.service"; | |
| import {ControlMessages} from "./control-messages.component"; | |
| @Page({ | |
| templateUrl: 'build/pages/login/login.html', | |
| directives: [ControlMessages] | |
| }) | |
| export class LoginPage { |
