fixing signout

This commit is contained in:
Jon Lambson 2017-08-21 11:21:00 -06:00
parent e29085b8c2
commit 47243870e2
8 changed files with 252 additions and 17 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html ng-app="launchpad" ng-strict> <html ng-app="launchpad" ng-strict ng-controller="loginCtrl as vm">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Launch-pad</title> <title>Launch-pad</title>
@ -9,7 +9,7 @@
<link rel="stylesheet" href="/css/styles.css"> <link rel="stylesheet" href="/css/styles.css">
</head> </head>
<body> <body class="{{ vm.currentPath }}">
<div ui-view class="splash-page"></div> <div ui-view class="splash-page"></div>
<div class="search-bar" ui-view="header"></div> <div class="search-bar" ui-view="header"></div>
<div class="container main-content"> <div class="container main-content">

View File

@ -4,6 +4,7 @@ app.controller('loginCtrl', [
var vm = this; var vm = this;
vm.currentPath = $location.url().substr(1);
vm.independentIssuer = false; vm.independentIssuer = false;
vm.oauth3 = Oauth3.oauth3 = Oauth3.oauth3 || Oauth3.create(location); vm.oauth3 = Oauth3.oauth3 = Oauth3.oauth3 || Oauth3.create(location);
vm.timers = {}; vm.timers = {};
@ -122,6 +123,10 @@ app.controller('loginCtrl', [
vm.newIssuer = vm.defaultIssuer; vm.newIssuer = vm.defaultIssuer;
vm.setIssuer(vm.defaultIssuer); vm.setIssuer(vm.defaultIssuer);
vm.initGetSession = function() {
return Auth.select(Auth.session);
}
vm.initListLoggedInProfiles = function () { vm.initListLoggedInProfiles = function () {
vm.activeProfiles = Auth.getActiveSessions(); vm.activeProfiles = Auth.getActiveSessions();
}; };
@ -136,6 +141,7 @@ app.controller('loginCtrl', [
}; };
vm.signOut = function () { vm.signOut = function () {
// TODO the sign-out url for each account should be fixed. // TODO the sign-out url for each account should be fixed.
return Auth.signOut().then(function () { return Auth.signOut().then(function () {
if (Auth.sessions.length === 0) { if (Auth.sessions.length === 0) {

View File

@ -32,7 +32,7 @@ app.controller('websiteCtrl', [
return $q.all(Auth.sessions.map(function (session) { return $q.all(Auth.sessions.map(function (session) {
return Auth.select(session).then(function (oauth3) { return Auth.select(session).then(function (oauth3) {
console.log('asdf');
return oauth3.api(apiname, {}).then(function (collection) { return oauth3.api(apiname, {}).then(function (collection) {
if (collection.error) { if (collection.error) {

View File

@ -64,12 +64,11 @@ app.factory('Auth', [
Auth.sessions.push(session); Auth.sessions.push(session);
}); });
return Auth.session; return Auth.session;
} }
, select: function (session) { , select: function (session) {
if (!session.issuer) { if (!session.issuer) {
throw new Error("session doesn't have an issuer");; throw new Error("session doesn't have an issuer");
} }
var name = session.token.sub + '@' + session.token.iss; var name = session.token.sub + '@' + session.token.iss;
@ -105,7 +104,6 @@ app.factory('Auth', [
, signOut: function () { , signOut: function () {
var session = Auth.session; var session = Auth.session;
var dapName = 'dap-' + session.subject + '|' + session.issuer; var dapName = 'dap-' + session.subject + '|' + session.issuer;
// TODO logout url should be created upon login and remain fixed throughout the duration of the session (or on session restoration) // TODO logout url should be created upon login and remain fixed throughout the duration of the session (or on session restoration)
return Auth.oauth3.logout().then(function () { return Auth.oauth3.logout().then(function () {
var obj = JSON.parse(localStorage.getItem(dapSessions) || '{}'); var obj = JSON.parse(localStorage.getItem(dapSessions) || '{}');

View File

@ -7,7 +7,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
add: function (opts) { add: function (opts) {
var providerUri = opts.audience; var providerUri = opts.audience;
var session = opts.session; var session = opts.session;
debugger;
return OAUTH3.request({ return OAUTH3.request({
method: 'POST' method: 'POST'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)

View File

@ -60,7 +60,7 @@
<a class="btn btn-default btn-sm" ng-click="vm.selectSession(session);">Use Account</a> <a class="btn btn-default btn-sm" ng-click="vm.selectSession(session);">Use Account</a>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<a class="btn btn-default btn-sm pull-right" ng-click="vm.signOut()">Sign Out</a> <a class="btn btn-default btn-sm pull-right" ng-if="vm.session.subject == session.subject" ng-click="vm.signOut()">Sign Out</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,12 +1,243 @@
<h2>Contacts</h2> <div class="home-container">
<ul> <div ng-hide="vm.single_contact">
<li ng-repeat="contact in contacts"> <div class="panel panel-default">
<div class="panel-heading">
<a ui-sref=".detail({ id: contact.id })" > {{ contact.name }}</a> <ul class="nav nav-tabs" role="tablist">
{{ contact.email }} <li role="presentation" class="active"><a href="!#contacts" class="quick-create-tab" aria-controls="contacts" role="tab" data-toggle="tab"><i class="fa fa-user-plus" aria-hidden="true"></i> Create contact</a></li>
<li role="presentation"><a href="!#groups" class="quick-create-tab" aria-controls="conversate" role="tab" data-toggle="tab"><i class="fa fa-users" aria-hidden="true"></i> Create a group</a></li>
</li> <li role="presentation"><a href="!#import_contacts" class="quick-create-tab" aria-controls="conversate" role="tab" data-toggle="tab"><i class="fa fa-users" aria-hidden="true"></i> Import Contacts</a></li>
</ul> </ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="contacts">
<div ng-hide="vm.contact_active" ng-click="vm.contact_active = true">
<input type="text" class="form-control" placeholder="First Name">
</div>
<div ng-show="vm.contact_active" class="media">
<div class="media-left">
<div class="image-thing"><i class="fa fa-user fa-3x" aria-hidden="true"></i></div>
</div>
<div class="media-body">
<div class="form-group">
<input type="text" class="form-control" placeholder="First Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Last Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Mobile Number">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Email or Daplie Address">
</div>
<div class="form-group">
<textarea name="name" class="form-control" rows="8" cols="80" placeholder="Notes"></textarea>
<br>
<div class="pull-right">
<button ng-click="vm.contact_active = false" type="button" name="button" class="btn btn-default">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div ui-view="detail"></div> <div ng-hide="vm.contacts_imported" class="contact-zero">
<div class="contact-zero-main">
<i class="fa fa-users fa-4x"></i>
<h3>You haven't added any contacts yet!</h3>
</div>
<div class="contact-zero-buttons button-container">
<button ng-click="vm.import_contacts()" class="btn btn-default" type="button">Import from Gmail</button>
</div>
</div>
<div ng-show="vm.contacts_imported">
<h4 class="text-center">Importing Contacts...</h4>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="30"
aria-valuemin="0" aria-valuemax="100" style="width:30%">
<span class="sr-only">30% Complete</span>
</div>
</div>
<h3 class="text-center">Recent Contacts</h3>
<table class="table">
<tr>
<td><button ng-click="vm.single_contact = true" class="btn btn-default">View</button></td>
<td>Best Friend</td>
<td>best@frind.com</td>
<td>555-555-5309</td>
</tr>
<tr>
<td><button ng-click="vm.single_contact = true" class="btn btn-default">View</button></td>
<td>Notbest Friend</td>
<td>not@best.com</td>
<td>555-867-5555</td>
</tr>
<tr>
<td><button ng-click="vm.single_contact = true" class="btn btn-default">View</button></td>
<td>Uncle Ben</td>
<td>uncle@ben.com</td>
<td>555-867-1234</td>
</tr>
</table>
<h3 class="text-center">Core to reconnect with these old friends?</h3>
<div class="contact-suggest">
<table class="table">
<tr>
<td>John Doe</td>
<td>john@doe.com</td>
<td>555-867-5309</td>
<td>
<button class="btn btn-sm">Send a message</button>
<button ng-click="vm.unlock('godfather')" class="btn btn-sm btn-danger">Nah</button>
</td>
</tr>
<tr>
<td>Bob Smith</td>
<td>bob@smith.com</td>
<td>555-867-5308</td>
<td>
<button class="btn btn-sm">Send a message</button>
<button ng-click="vm.unlock('godfather')" class="btn btn-sm btn-danger">Nah</button>
</td>
</tr>
<tr>
<td>Jane Austin</td>
<td>jane@austin.com</td>
<td>555-867-5307</td>
<td>
<button class="btn btn-sm">Send a message</button>
<button ng-click="vm.unlock('godfather')" class="btn btn-sm btn-danger">Nah</button>
</td>
</tr>
</table>
</div>
</div>
</div>
<div ng-show="vm.single_contact">
<div class="contact-single-header">
<i class="fa fa-user fa-4x"></i>
<span class="contact-single-name">John Doe</span>
<div class="contact-single-info">
<p>john@doe.com</p>
<p>555-867-5309</p>
<button class="btn btn-primary">Send a Message</button>
</div>
</div>
<br/>
<br/>
<div class="panel panel-default">
<div class="panel-heading">
<div ng-init="vm.contact_view = 'messages'" class="flex-row space-around">
<div ng-click="vm.contact_view = 'messages'">
<p class="panel-title"><i class="fa fa-users" aria-hidden="true"></i> Conversations</p>
</div>
<span class="seperator">|</span>
<div ng-click="vm.contact_view = 'photos'">
<p class="panel-title"><i class="fa fa-photo" aria-hidden="true"></i> Photos</p>
</div>
<span class="seperator">|</span>
<div ng-click="vm.contact_view = 'files'">
<p class="panel-title"><i class="fa fa-file" aria-hidden="true"></i> Files</p>
</div>
<span class="seperator">|</span>
<p class="panel-title"><i class="fa fa-bars" aria-hidden="true"></i> More</p>
</div>
</div>
<div ng-show="'messages' === vm.contact_view" class="panel-body contact-bordered contact-conversation">
<p>Me: Hey John, did you know that you are my best friend?</p>
<p>John: No way! You're my best friend, too!</p>
<p>Me: Wow! We sure are awesome friends together! :)</p>
</div>
<div ng-show="'photos' === vm.contact_view" class="panel-body contact-bordered contact-photos">
<div class="col-lg-3"><i class="fa fa-4x fa-picture-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-file-image-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-file-image-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-file-image-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-picture-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-file-image-o"></i></div>
<div class="col-lg-3"><i class="fa fa-4x fa-picture-o"></i></div>
</div>
<div ng-show="'files' === vm.contact_view" class="panel-body contact-bordered contact-files">
<div class="contact-file-placeholder">
<i class="fa fa-file fa-4x"></i>
<p>filename.ext</p>
</div>
<div class="contact-file-placeholder">
<i class="fa fa-file fa-4x"></i>
<p>filename.ext</p>
</div>
<div class="contact-file-placeholder">
<i class="fa fa-file fa-4x"></i>
<p>filename.ext</p>
</div>
<div class="contact-file-placeholder">
<i class="fa fa-file fa-4x"></i>
<p>filename.ext</p>
</div>
<div class="contact-file-placeholder">
<i class="fa fa-file fa-4x"></i>
<p>filename.ext</p>
</div>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Remember when...?</h3>
</div>
<div class="panel-body contact-remember-body">
<div class="remember-item">
<div class="remember-item-header">Taken Feb 20, 2017</div>
<div class="remember-img-placeholder">
<i class="fa fa-photo fa-4x"></i>
</div>
</div>
<div class="remember-item">
<div class="remember-item-header">Sent on June 5, 2017</div>
<div class="remember-text-placeholder">
<p>Hey Jane,</p>
<p>Love the new do!</p>
<p>You're so lucky to have great<br/> hair I'm super jealous...</p>
</div>
</div>
<div class="remember-item">
<div class="remember-item-header">Shared on Ap...</div>
<div class="remember-music-placeholder">
<i class="fa fa-music fa-3x"></i>
<div class="remember-music-text">
<p>Come Fly with Me</p>
<p>Frank Sinatra</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<nav class="navbar navbar-default navbar-fixed-top"> <nav class="navbar navbar-default navbar-fixed-top" ng-init="vm.initGetSession()">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">