Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.workingDirectories": [{ "mode": "auto" }]
}
23 changes: 23 additions & 0 deletions with-vue-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
15 changes: 15 additions & 0 deletions with-vue-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Authorizer Example with Vue JS

## Local Setup

- Clone the repo `git clone https://github.com/authorizerdev/examples.git`
- Change directory to react JS `cd with-vue-js`
- Install dependencies `yarn install`
- Start project `yarn serve`
- To get a minified production build `yarn build`
- Lint and fix files `yarn lint`

## CodeSandboxLink:

- App: https://dzfgp8.csb.app/
- Code: https://codesandbox.io/s/authorizer-vue-example-dzfgp8
5 changes: 5 additions & 0 deletions with-vue-js/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
19 changes: 19 additions & 0 deletions with-vue-js/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
47 changes: 47 additions & 0 deletions with-vue-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "with-vue-js",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 3000",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"authorizer-vue-ts": "^1.0.8",
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {
"vue/multi-word-component-names": "off"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
Binary file added with-vue-js/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions with-vue-js/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
44 changes: 44 additions & 0 deletions with-vue-js/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<div :style="{ display: 'flex', justifyContent: 'center' }">
<div
:style="{
width: '400px',
margin: `10px auto`,
border: `1px solid #D1D5DB`,
padding: `25px 20px`,
'border-radius': `5px`,
}"
>
<authorizer-provider
:config="{
authorizerURL: 'https://demo.authorizer.dev',
redirectURL: window.location.origin,
clientID: '96fed66c-9779-4694-a79a-260fc489ce33',
}"
:onStateChangeCallback="stateChangeCallback"
>
<router-view />
</authorizer-provider>
</div>
</div>
</template>

<script>
import { AuthorizerProvider } from 'authorizer-vue-ts';
export default {
components: {
'authorizer-provider': AuthorizerProvider,
},
setup() {
const stateChangeCallback = (state) => {
console.log('state changes from client ==>> ', state);
};
return {
stateChangeCallback,
window,
};
},
};
</script>

<style scoped></style>
Binary file added with-vue-js/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions with-vue-js/src/assets/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
font-family: -apple-system, system-ui, sans-serif;
color: #374151;
font-size: 14px;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

#app {
display: flex;
height: 100vh;
flex-direction: column;
justify-content: center;
align-items: center;
}
58 changes: 58 additions & 0 deletions with-vue-js/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>

<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
8 changes: 8 additions & 0 deletions with-vue-js/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createApp } from 'vue';
import 'authorizer-vue-ts/dist/style.css';

import App from './App.vue';
import router from './router';
import './assets/main.css';

createApp(App).use(router).mount('#app');
22 changes: 22 additions & 0 deletions with-vue-js/src/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createRouter, createWebHistory } from 'vue-router';
import Login from './views/Login.vue';
import ResetPassword from './views/ResetPassword.vue';
import Dashboard from './views/Dashboard.vue';

export default createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
component: Login,
},
{
path: '/reset-password',
component: ResetPassword,
},
{
path: '/dashboard',
component: Dashboard,
},
],
});
61 changes: 61 additions & 0 deletions with-vue-js/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<div>
<h1>Hey 👋,</h1>
<p>Thank you for joining Authorizer demo app.</p>
<p>
Your email address is
<a
href="`mailto:${user?.email}`"
:style="{
color: '#3B82F6',
}"
>
{{ user?.email }}
</a>
</p>

<br />
<h3 v-if="loading">Processing....</h3>
<h3
v-else
:style="{
color: '#3B82F6',
cursor: 'pointer',
}"
@click="logout"
>
Logout
</h3>
</div>
</template>

<script>
import { inject, watch } from 'vue';
import { useRouter } from 'vue-router';
export default {
name: 'Dashboard',
setup() {
const useAuthorizer = inject('useAuthorizer');
const { user, loading, token, logout } = useAuthorizer();
const router = useRouter();
watch(
token,
function (newvalue) {
if (!newvalue) {
router.push('/');
}
},
{
immediate: true,
}
);
return {
user,
loading,
logout,
};
},
};
</script>

<style scoped></style>
44 changes: 44 additions & 0 deletions with-vue-js/src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<div>
<h1 :style="{ textAlign: 'center' }">Welcome to Authorizer</h1>
<br />
<authorizer-root :onLogin="onLogin" />
</div>
</template>

<script>
import { inject, watch } from 'vue';
import { useRouter } from 'vue-router';
import { AuthorizerRoot } from 'authorizer-vue-ts';
export default {
name: 'Login',
components: {
'authorizer-root': AuthorizerRoot,
},
setup() {
const useAuthorizer = inject('useAuthorizer');
const { token } = useAuthorizer();
const router = useRouter();
const onLogin = () => {
console.log('test login');
};
watch(
token,
(newvalue) => {
if (newvalue) {
console.log('access token ==>> ', token.value.access_token);
router.push('/dashboard');
}
},
{
immediate: true,
}
);
return {
onLogin,
};
},
};
</script>

<style scoped></style>
Loading