Skip to content

Commit

Permalink
feat: login with redirected mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
saadjutt01 committed Sep 9, 2021
1 parent 4275a7f commit 059db9f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
<script>
function initSasJs() {
sasjs = new SASjs.default({
appLoc: '/Public/app/minimal-seed-app',
appLoc: '/Public/app2/minimal-seed-app',
serverType: 'SASVIYA',
serverUrl: '',
debug: false,
loginMechanism: 'Redirected',
})
sasjs.checkSession().then((res) => {
if (res.isLoggedIn) afterLogin()
Expand Down
4 changes: 2 additions & 2 deletions src/sasjs.js

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions src/scripts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
let sasjs
let username
let password

function login() {
const username = document.querySelector('#username').value
const password = document.querySelector('#password').value
username = document.querySelector('#username').value
password = document.querySelector('#password').value
sasjs.logIn(username, password).then((response) => {
if (response.login === false) {
} else {
if (response.isLoggedIn) {
afterLogin()
}
})
Expand All @@ -23,8 +24,13 @@ function afterLogin() {
}

function loadStartupData() {
if (sasjs) {
sasjs.request('services/common/appinit', null, true).then((response) => {
if (!sasjs) return

sasjs
.request('services/common/appinit', null, undefined, async () => {
await sasjs.logIn(username, password)
})
.then((response) => {
let responseJson
try {
responseJson = response
Expand All @@ -42,16 +48,20 @@ function loadStartupData() {
}
}
})
}
}

function loadData() {
const areasDropdown = document.querySelector('#areas-dropdown')
const selectedArea = areasDropdown.options[areasDropdown.selectedIndex].value
sasjs
.request('services/common/getdata', {
areas: [{ area: selectedArea }],
})
.request(
'services/common/getdata',
{ areas: [{ area: selectedArea }] },
undefined,
async () => {
await sasjs.logIn(username, password)
}
)
.then((response) => {
const responseJson = response
if (responseJson && responseJson.springs && responseJson.springs) {
Expand Down

0 comments on commit 059db9f

Please sign in to comment.