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 { browser, by, element } from 'protractor'; | |
| export class LoginPage { | |
| private credentias = { | |
| username: 'test', | |
| password: 'test' | |
| }; | |
| navigateTo() { | |
| return browser.get('/login'); |
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 { PublicPage } from './public.po'; | |
| describe('protractor-tutorial - Public page', () => { | |
| let page: PublicPage; | |
| beforeEach(() => { | |
| page = new PublicPage(); | |
| }); | |
| it('when user browses to our app he should see the default “public” screen', () => { |
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 { browser, by, element } from 'protractor'; | |
| export class PublicPage { | |
| navigateTo() { | |
| return browser.get('/'); // we can navigate to '/' for get pblic page since this is the default route | |
| } | |
| getPageTitleText() { | |
| return element(by.css('app-root h1')).getText(); | |
| } |
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 { Injectable } from '@angular/core'; | |
| import { | |
| CanActivate, Router, | |
| ActivatedRouteSnapshot, | |
| RouterStateSnapshot | |
| } from '@angular/router'; | |
| import { AuthenticationService } from '../_services/index'; | |
| @Injectable() | |
| export class AuthGuard implements CanActivate { |
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 { Routes, RouterModule } from '@angular/router'; | |
| import { LoginComponent } from './login/index'; | |
| import { ProtectedComponent } from './protected/index'; | |
| import { PublicComponent } from './public/index'; | |
| import { AuthGuard } from './_guards/index'; | |
| const appRoutes: Routes = [ | |
| { path: 'login', component: LoginComponent }, | |
| { path: 'protected', component: ProtectedComponent, canActivate: [AuthGuard] }, |
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 { Injectable } from '@angular/core'; | |
| import { Http, Headers, Response } from '@angular/http'; | |
| import { Observable } from 'rxjs'; | |
| import 'rxjs/add/operator/map' | |
| @Injectable() | |
| export class AuthenticationService { | |
| public token: string; | |
| public redirectUrl; | |
| constructor(private http: Http) { |
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
| var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| // "http-proxy-middleware": "~0.17.2", in package.json | |
| var proxyMiddleware = require('http-proxy-middleware'); | |
| var url = require('url'); | |
| var webpack = require('webpack'); | |
| var request = require('request'); | |
| var prxy = proxyMiddleware('/api', { | |
| target: 'http://my-backend-server', |
NewerOlder