-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: migrate loopback-example-passport repo as lb4 example
- Loading branch information
1 parent
fd38ff5
commit 6a68ec4
Showing
43 changed files
with
980 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
npm-debug.log | ||
/dist | ||
# Cache used by TypeScript's incremental build | ||
*.tsbuildinfo |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
coverage/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: '@loopback/eslint-config', | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# Transpiled JavaScript files from Typescript | ||
/dist | ||
|
||
# Cache used by TypeScript's incremental build | ||
*.tsbuildinfo |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"recursive": true, | ||
"require": "source-map-support/register" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
*.json |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"trailingComma": "all" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright IBM Corp. 2014,2015. All Rights Reserved. | ||
// Node module: loopback-example-passport | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
'use strict'; | ||
|
||
const express = require('express'); | ||
const path = require('path'); | ||
const ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn; | ||
|
||
const app = (module.exports = express()); | ||
|
||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'jade'); | ||
|
||
app.get('/', function(req, res, next) { | ||
res.render('pages/index', {user: req.user, url: req.url}); | ||
}); | ||
|
||
app.get('/auth/account', ensureLoggedIn('/login'), function(req, res, next) { | ||
res.render('pages/loginProfiles', { | ||
user: req.user, | ||
url: req.url, | ||
}); | ||
}); | ||
|
||
app.get('/local', function(req, res, next) { | ||
res.render('pages/local', { | ||
user: req.user, | ||
url: req.url, | ||
}); | ||
}); | ||
|
||
app.get('/ldap', function(req, res, next) { | ||
res.render('pages/ldap', { | ||
user: req.user, | ||
url: req.url, | ||
}); | ||
}); | ||
|
||
app.get('/signup', function(req, res, next) { | ||
res.render('pages/signup', { | ||
user: req.user, | ||
url: req.url, | ||
}); | ||
}); | ||
|
||
app.get('/login', function(req, res, next) { | ||
res.render('pages/login', { | ||
user: req.user, | ||
url: req.url, | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
doctype html | ||
html(lang="en") | ||
include ../partials/head | ||
body(style="padding-top: 70px; padding-bottom: 50px;") | ||
include ../partials/navigation | ||
include ../partials/banner | ||
include ../partials/footer | ||
block scripts |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
.jumbotron | ||
h1 Passport Authentication Example | ||
h2 From | ||
img(src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAABkCAMAAABn2a/3AAAAsVBMVEUAAAD///8HWCt8vDMHWCt8vDMHWCt8vDMHWCt8vDMHWCsebC18vDMHWCtpqzJ8vDMHWCt8vDMHWCt8vDMHWCtvsTJ8vDMHWCt8vDMHWCsncy18vDMHWCskcS1ytDJ8vDMHWCt8vDMHWCsodS1rrjJ8vDMHWCsebC10tTJ8vDMHWCsOXiwWZSwday0kcS0sdy4zfi46hC9Cii9JkDBQlzBXnTFfozFmqTJtsDJ1tjN8vDORSmJOAAAAKnRSTlMAABAQICAwMEBAUFBQYGBgcHCAgI+Pj5+fr6+vv7+/v8/P39/f3+/v7+9ljT9GAAAHFElEQVR42u2b63bcJhCAKcYKq1i1jNVqlai1otQ0llOnddPE3vd/sCLEXbCS3bPZ9HjmR5JFoIFPMDMMBP0AskcQIAA8gAfwAB7AA3gAD+ABATyAB/AAHsADeAAP4AE8IIAH8AAewAN4AA/gATyABwTwrMMzCSnrtht421YFQa5g9C0lo6N8W52OkESv2sGRrjD9w1X7Tfs39YMeBw7thjr2ZcohEN2/gg8vBg+pR9WczR6wIY5H0BxeDh4WTA0zp4YEHvnPF49H2R1elzRndfcC8RAS4CmtCSLKHusSUvGXhQcLo8OwgyfvB17qp8VU6vg0zLIXhCfjcu0QxaGnrfrbXXNdpOFUjSnR/ChrRIQ09G1dmAnI2lFHV+f+nM1F1fEJb5ty5jHzqu0HGWmVNtDZgyehZBxgJZu1VebVp6yW2ru2yk2cEjqms8vXetKQdnRc2Jjillg8fQqPb65LN0BSE4s4Zb3te8X99pULCDP/aZct4CFNVEkQs7WmZdF771f+Wgxdt5J/vrra7T44Jodn6Oy3O6/LbEh1KYLHK2l1bORRCCy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fa/t4MhZuKqzETZpCIjfvXOweP+JIlVbGh2gI3dhVMqEmZRZ3ZVH/KXNPeHUcaT7aU0KiZI3ZfPlei9lLTNkhvDZwcKJf5Vb1eOE7hIU5u8a/Hseifjw6eyRr0QW/1Ey5TtjSKJzfTsNWDbtACnnkOK8Djia+k95WUXhcdR2YtiGnirwMPj5M2etCFfwR45puuLp4Oa+fb6UjOdA+eMDe6hAdVycTsXH0qWxjxQjE8Judzl8RTx7J0CTxhB03H9+ER891Mg2YFnqQSY1ENA5zC0+E0ntdpPCRMi9sjMET5Mh5/KlSJMxk6a5nljI1HOLWbE0nhSSkZQfB5pjmCp4rcvdhcT3S2H+7jeKTTytzjmbbwD1wUvH56fTtKFR4zlqaS4wMrWTczxy2xlnYFe408mSmpg1s4Zib2jAShY6Ea9VXi5s7Fze56M2Z9HiJ47LEQIvLeESWJK0mLB7GpxsuXapLHbE9QgmeXpmzcQ2iWeuFmc7o5R+jKHuc4pvl9caxLWM5I1NKuD3PfYuGzbi/eiZDHxyPC6PHnzeXJsegIC9OycR7QXB8iZEfBc/5qeylThm72XZ7nbE8ROiKeQBp0FDxGfvQDjV82CH1HeHp8IDyrJ6W7Ee0LhL4nPB1BB8HTPOW9+o7D/LD4uHgO87HY0D31lpC8SlkTdHzJSjYFNTXLDqOhKJ/TqJkjhZvv8J8GAA/gATyAB/AAHsADAngAD+ABPIAH8AAewAN4QAAP4AE8gAfwAB7AA3gADwjgATyA58DyL4we9xSOmoFDAAAAAElFTkSuQmCC", alt="StrongLoop", width=190) | ||
p | ||
a.btn.btn-lg.btn-primary(href='http://docs.strongloop.com/display/public/LB/LoopBack#getting-started', role='button') View LoopBack docs » | ||
|
||
.row | ||
.col-md-12 | ||
h1 Sample Functionality | ||
p.lead In this sample application you can: | ||
ul | ||
li | ||
a(href='/signup') Signup for a local account | ||
li | ||
a(href='/login') Login to your account using either a local account or social accounts |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
.row | ||
.col-md-6.col-md-offset-3 | ||
form(role='form', action='/auth/ldap', method='post') | ||
.form-group | ||
label(for='username') Your username | ||
input#username.form-control(type='text', name='username', placeholder='Enter username') | ||
.form-group | ||
label(for='password') Password | ||
input#password.form-control(type='password', name='password', placeholder='Password') | ||
button.btn.btn-default(type='submit') Submit | ||
br | ||
if (messages.error) | ||
p | ||
span(style="color:red")= messages.error |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
.row | ||
.col-md-6.col-md-offset-3 | ||
form(role='form', action='/auth/local', method='post') | ||
.form-group | ||
label(for='username') Your username | ||
input#username.form-control(type='text', name='username', placeholder='Enter username') | ||
.form-group | ||
label(for='password') Password | ||
input#password.form-control(type='password', name='password', placeholder='Password') | ||
button.btn.btn-default(type='submit') Submit | ||
br | ||
if (messages.error) | ||
p | ||
span(style="color:red")= messages.error |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
.row | ||
.col-md-12 | ||
h1 Login: | ||
ul.list-inline.list-unstyled | ||
li | ||
a.btn.btn-primary(href='/local') Login with local account | ||
li | ||
a.btn.btn-primary(href='/ldap') Login with ldap account | ||
li | ||
a.btn.btn-primary(href="/auth/facebook") Login with Facebook | ||
li | ||
a.btn.btn-primary(href="/auth/google") Login with Google | ||
li | ||
a.btn.btn-primary(href="/auth/twitter") Login with Twitter | ||
br | ||
if (messages.error) | ||
p | ||
span(style="color:red")= messages.error |
24 changes: 24 additions & 0 deletions
24
examples/passport-facebook/client/views/pages/loginProfiles.jade
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
h2 Third Party Profile(s) | ||
p.small | ||
if user.profiles.length !== 0 | ||
each val in user.profiles | ||
h4= val.provider + ':' | ||
p.small= JSON.stringify(val) | ||
else | ||
| NONE | ||
h2 Linked Account(s) | ||
ul.list-inline.list-unstyled | ||
li | ||
a.btn.btn-primary(href="/link/facebook") Link Facebook | ||
li | ||
a.btn.btn-primary(href="/link/google") Link Google | ||
p.small | ||
if user.accounts.length !== 0 | ||
each val in user.accounts | ||
h4= val.provider + ':' | ||
p.small= JSON.stringify(val) | ||
else | ||
| NONE |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extends ../layouts/layout | ||
|
||
block content | ||
.row | ||
.col-md-6.col-md-offset-3 | ||
if user && user.username | ||
h1 User Logged in! | ||
h3 Hello #{user.username} | ||
ul | ||
li | ||
a(href='/') Home | ||
li | ||
a(href='/auth/logout') Log Out | ||
|
||
//- form#newuser(role='form', action='/api/users', method='post') | ||
form(role='form', action='/signup', method='post') | ||
.form-group | ||
label(for='username') Your Name | ||
input.form-control(type='text', name='username', placeholder='Enter your name') | ||
.form-group | ||
label(for='email') Your Email address | ||
input.form-control(type='email', name='email', placeholder='Enter your email address') | ||
.form-group | ||
label(for='password') Your Password | ||
input.form-control(type='password', name='password', placeholder='Password') | ||
button.btn.btn-default(type='submit') Submit | ||
br | ||
if (messages.error) | ||
p | ||
span(style="color:red")= messages.error |
10 changes: 10 additions & 0 deletions
10
examples/passport-facebook/client/views/partials/banner.jade
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.container | ||
if user && user.username | ||
.row | ||
.col-md-12 | ||
.well | ||
h1 User Logged in! | ||
h3 Hello: #{user.username} | ||
p.small User Id: #{user.id} | ||
p.small Email: #{user.email} | ||
block content |
13 changes: 13 additions & 0 deletions
13
examples/passport-facebook/client/views/partials/footer.jade
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
hr(style="margin-top: 50px;") | ||
.footer(style="text-align: center;") | ||
p | ||
| Copyright © | ||
script. | ||
var d = new Date(); | ||
document.write(d.getFullYear()); | ||
| StrongLoop, Inc., All Rights Reserved. | ||
a(href='/status') Server Status. | ||
|
||
//- Load Scripts | ||
script(src='//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js') | ||
script(src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js') |
30 changes: 30 additions & 0 deletions
30
examples/passport-facebook/client/views/partials/head.jade
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
head | ||
//- Behavioral Meta Data | ||
meta(charset='utf-8') | ||
meta(name='x-csrf-token', content=_csrf) | ||
meta(http-equiv='X-UA-Compatible', content='IE=edge') | ||
meta(name='viewport', content='width=device-width, initial-scale=1.0') | ||
|
||
//- SEO Meta Data | ||
title LoopBack API Server | ||
meta(name='author', content='') | ||
meta(name='description', content='') | ||
meta(name='keywords', content='') | ||
|
||
//- Styles | ||
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css') | ||
style. | ||
.navbar-brand { | ||
background-image: url(http://loopback.io/images/loopback.svg); | ||
background-repeat: no-repeat; | ||
background-size: 40px; | ||
background-position: left center; | ||
padding-left: 45px; | ||
margin-top: -1px; | ||
margin-left: 15px; | ||
font-size: 22px; | ||
color: #07582B !important; | ||
} | ||
h2 { | ||
color: #07582B; | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/passport-facebook/client/views/partials/navigation.jade
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
nav.navbar.navbar-default.navbar-fixed-top(role='navigation') | ||
.container | ||
.navbar-header | ||
button.navbar-toggle.collapsed(type='button', data-toggle='collapse', data-target='#navbar', aria-expanded='false', aria-controls='navbar') | ||
span.sr-only Toggle navigation | ||
span.icon-bar | ||
span.icon-bar | ||
span.icon-bar | ||
a.navbar-brand(href='/') LoopBack | ||
#navbar.navbar-collapse.collapse | ||
if user | ||
//- User *is* logged In | ||
ul.nav.navbar-nav.navbar-right | ||
li | ||
a(href='/explorer') API Explorer | ||
li(class=url=='/auth/account'?'active':undefined) | ||
a(href='/auth/account') View Account | ||
li | ||
a(href='/auth/logout') Log Out | ||
else | ||
//- User is *not* Logged In | ||
ul.nav.navbar-nav.navbar-right | ||
li(class=url=='/'?'active':undefined) | ||
a(href='/') Home | ||
li | ||
a(href='/explorer') API Explorer | ||
li(class=url=='/login'?'active':undefined) | ||
a(href='/login') Log in | ||
li(class=url=='/signup'?'active':undefined) | ||
a(href='/signup') Sign Up |
Oops, something went wrong.