Skip to content

Commit 1e57738

Browse files
authored
Merge pull request #65 from wviriya/refresh-functions-v4
Upgrade Vue and dependencies
2 parents fe22805 + 904f51a commit 1e57738

File tree

7 files changed

+7885
-26614
lines changed

7 files changed

+7885
-26614
lines changed

web/serverless-microservices-web/.eslintrc.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ module.exports = {
44
node: true
55
},
66
'extends': [
7-
'plugin:vue/essential',
8-
'@vue/standard'
7+
'plugin:vue/essential'
98
],
109
rules: {
11-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
1210
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
1311
},
1412
parserOptions: {

web/serverless-microservices-web/package-lock.json

Lines changed: 7803 additions & 26544 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/serverless-microservices-web/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
"lint": "vue-cli-service lint"
1111
},
1212
"dependencies": {
13-
"@aspnet/signalr": "^1.0.3",
14-
"EventEmitter": "^1.0.0",
15-
"axios": "^0.21.1",
16-
"bootstrap-vue": "^2.0.0-rc.12",
17-
"msal": "^0.2.2",
18-
"vue": "^2.5.17",
13+
"@azure/msal-browser": "^2.19.0",
14+
"@microsoft/signalr": "^6.0.0",
15+
"axios": "^0.21.4",
16+
"bootstrap-vue": "^2.21.2",
17+
"core-js": "^3.6.5",
18+
"vue": "^2.6.14",
1919
"vue-blockui": "^1.1.7",
20-
"vue-flatpickr-component": "^6.2.0",
21-
"vue-izitoast": "^1.1.0",
22-
"vue-router": "^3.0.1",
23-
"vuex": "^3.0.1",
24-
"signalrcoreclientpreview": "~1.0.0-preview1-t000"
20+
"vue-izitoast-2": "^1.2.5",
21+
"vue-router": "^3.5.3",
22+
"vuex": "^3.6.2"
2523
},
2624
"devDependencies": {
27-
"@vue/cli-plugin-babel": "^3.0.0",
28-
"@vue/cli-plugin-eslint": "^3.0.0",
29-
"@vue/cli-service": "^3.0.0",
30-
"@vue/eslint-config-standard": "^3.0.0",
31-
"vue-template-compiler": "^2.5.17"
25+
"@vue/cli-plugin-babel": "~4.5.0",
26+
"@vue/cli-plugin-eslint": "~4.5.0",
27+
"@vue/cli-service": "~4.5.0",
28+
"babel-eslint": "^10.1.0",
29+
"eslint": "^6.7.2",
30+
"eslint-plugin-vue": "^6.2.2",
31+
"vue-template-compiler": "^2.6.11"
3232
}
3333
}

web/serverless-microservices-web/src/components/SignalRTrips.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<template></template>
2-
1+
<template>
2+
<div></div>
3+
</template>
34
<script>
4-
import * as signalR from "@aspnet/signalr";
5+
import * as signalR from "@microsoft/signalr";
56
import { createNamespacedHelpers } from "vuex";
67
import { getPassenger } from "@/api/passengers";
78
const { mapGetters: commonGetters } = createNamespacedHelpers("common");
@@ -47,9 +48,6 @@ export default {
4748
return signalRInfo;
4849
} else {
4950
console.log(`getSignalRInfo Response status: ${rawResponse.status}`);
50-
throw `Could not obtain SignalR info. Response was ${
51-
rawResponse.status
52-
}`;
5351
return null;
5452
}
5553
}

web/serverless-microservices-web/src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import store from './store/index';
77

88
import BootstrapVue from 'bootstrap-vue';
99
import BlockUI from 'vue-blockui';
10-
import VueIziToast from 'vue-izitoast';
10+
import VueIziToast from 'vue-izitoast-2';
1111
import 'izitoast/dist/css/iziToast.min.css';
1212

1313
Vue.use(BootstrapVue);

web/serverless-microservices-web/src/utils/Authentication.js

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,75 @@
1-
import { UserAgentApplication, Logger } from 'msal';
1+
import { LogLevel, PublicClientApplication } from '@azure/msal-browser';
22

33
const ACCESS_TOKEN = 'rideshare_access_token';
4-
const ID_TOKEN = 'rideshare_id_token';
5-
const EXPIRES_AT = 'rideshare_expires_at';
64
const USER_DETAILS = 'rideshare_user_details';
5+
let _user = null;
6+
let _account = null;
7+
let _loginRequest;
8+
9+
710

8-
let logger = new Logger((level, message, containsPii) => {
9-
console.log(message);
10-
});
1111

1212
export class Authentication {
1313
constructor() {
1414
// The window values below should by set by public/js/settings.js
15-
this._scopes = window.authScopes;
16-
this._clientId = window.authClientId;
17-
this._authority = window.authAuthority;
18-
19-
var cb = this._tokenCallback.bind(this);
20-
var opts = {
21-
validateAuthority: false
15+
const msalConfig = {
16+
auth: {
17+
clientId: window.authClientId,
18+
authority: window.authAuthority
19+
},
20+
cache: {
21+
cacheLocation: 'localStorage'
22+
},
23+
system: {
24+
loggerOptions: {
25+
loggerCallback: (level, message, containsPii) => {
26+
if (containsPii) {
27+
return;
28+
}
29+
switch (level) {
30+
case LogLevel.Error:
31+
console.error(message);
32+
return;
33+
case LogLevel.Info:
34+
console.info(message);
35+
return;
36+
case LogLevel.Verbose:
37+
console.debug(message);
38+
return;
39+
case LogLevel.Warning:
40+
console.warn(message);
41+
return;
42+
default:
43+
return;
44+
}
45+
},
46+
logLevel: LogLevel.Verbose
47+
}
48+
}
2249
};
23-
this._userAgentApplication = new UserAgentApplication(
24-
this._clientId,
25-
this._authority,
26-
cb,
27-
opts
28-
);
29-
}
3050

31-
_tokenCallback(errorDesc, token, error, tokenType) {
32-
this._error = error;
33-
if (tokenType === 'access_token') {
34-
//localStorage.setItem(ACCESS_TOKEN, token);
35-
// Please note: do NOT do this in production! Should grab this value from the auth service.
36-
//let expiresAt = 60 * 1000 + new Date().getTime();
37-
//localStorage.setItem(EXPIRES_AT, expiresAt);
38-
this._token = token;
39-
} else {
40-
//localStorage.removeItem(ACCESS_TOKEN);
41-
}
51+
this._publicClientApplication = new PublicClientApplication(msalConfig);
52+
53+
_loginRequest = {
54+
scopes: window.authScopes
55+
};
4256
}
4357

4458
getUser() {
45-
return this._userAgentApplication.getUser();
59+
return this._user;
4660
}
4761

4862
getError() {
4963
return this._error;
5064
}
5165

5266
getAccessToken() {
53-
return this._userAgentApplication.acquireTokenSilent(this._scopes).then(
67+
return this._publicClientApplication.acquireTokenSilent(_loginRequest).then(
5468
accessToken => {
5569
return accessToken;
5670
},
5771
error => {
58-
return this._userAgentApplication.acquireTokenPopup(this._scopes).then(
72+
return this._publicClientApplication.acquireTokenPopup(_loginRequest).then(
5973
accessToken => {
6074
return accessToken;
6175
},
@@ -68,10 +82,11 @@ export class Authentication {
6882
}
6983

7084
login() {
71-
//this._userAgentApplication.loginRedirect(this._scopes);
72-
return this._userAgentApplication.loginPopup(this._scopes).then(
85+
return this._publicClientApplication.loginPopup(_loginRequest).then(
7386
idToken => {
74-
const user = this._userAgentApplication.getUser();
87+
_account = idToken.account;
88+
const user = idToken.account.user;
89+
_user = user;
7590
if (user) {
7691
return user;
7792
} else {
@@ -85,19 +100,22 @@ export class Authentication {
85100
}
86101

87102
logout() {
88-
this._userAgentApplication.logout();
103+
const logoutRequest = {
104+
account: _account.homeAccountId,
105+
};
106+
this._publicClientApplication.logoutPopup(logoutRequest);
89107
}
90108

91109
isAuthenticated() {
92110
return !!this.getUser();
93111
}
94112

95113
getAccessTokenOrLoginWithPopup() {
96-
return this._userAgentApplication
97-
.acquireTokenSilent(this._scopes)
114+
return this._publicClientApplication
115+
.acquireTokenSilent(_loginRequest)
98116
.catch(err => {
99-
return this._userAgentApplication.loginPopup().then(() => {
100-
return this._userAgentApplication.acquireTokenSilent(this._scopes);
117+
return this._publicClientApplication.loginPopup().then(() => {
118+
return this._publicClientApplication.acquireTokenSilent(_loginRequest);
101119
});
102120
});
103121
}

web/serverless-microservices-web/vue.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module.exports = {
22
css: {
33
extract: false
44
},
5-
6-
baseUrl: undefined,
75
outputDir: undefined,
86
assetsDir: undefined,
97
runtimeCompiler: true,

0 commit comments

Comments
 (0)