Skip to content

Commit ede22f8

Browse files
committed
make vidis login work again...
1 parent d40385e commit ede22f8

5 files changed

Lines changed: 43 additions & 18 deletions

File tree

‎src/client/communication/Data.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export type TeacherData = {
168168
export type LoginRequest = {
169169
username: string,
170170
password: string,
171-
language: number
171+
language: number,
172+
singleUseToken: string | null
172173
}
173174

174175
export type TicketLoginRequest = {
@@ -182,7 +183,8 @@ export type LoginResponse = {
182183
classdata: ClassData[], // null if !is_teacher
183184
workspaces: Workspaces,
184185
csrfToken: string,
185-
isTestuser: boolean
186+
isTestuser: boolean,
187+
vidis_id_token?: string
186188
}
187189

188190
export type LogoutRequest = {

‎src/client/main/Login.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import jQuery from "jquery";
1010
export class Login {
1111

1212
loggedInWithVidis: boolean = false;
13+
vidis_id_token: string = "";
1314

1415
constructor(private main: Main) {
1516
new AutoLogout(this);
@@ -120,8 +121,8 @@ export class Login {
120121
// window.location.href = 'index.html';
121122

122123
if (this.loggedInWithVidis) {
123-
window.location.assign("https://aai-test.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT=" + this.main.user.vidis_sub + "&post_logout_redirect_uri=https%3A%2F%2Fwww.sql-ide.de");
124-
// window.location.assign("https://aai.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT=" + this.main.user.vidis_sub + "&post_logout_redirect_uri=https%3A%2F%2Fwww.sql-ide.de");
124+
window.location.assign("https://aai-test.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT=" + this.vidis_id_token + "&post_logout_redirect_uri=https%3A%2F%2Fonline-ide.de/vidisLogout");
125+
// window.location.assign("https://aai.vidis.schule/auth/realms/vidis/protocol/openid-connect/logout?ID_TOKEN_HINT=" + this.vidis_id_token + "&post_logout_redirect_uri=https%3A%2F%2Fonline-ide.de/vidisLogout");
125126
} else {
126127
window.location.assign("/" + (isSilent ? "?silent=true" : ""));
127128

@@ -164,17 +165,21 @@ export class Login {
164165
$loginSpinner.show();
165166

166167
let loginRequest: LoginRequest = {
167-
username: <string>jQuery('#login-username').val(),
168-
password: <string>jQuery('#login-password').val(),
169-
language: 1
168+
username: singleUseToken ? "" : <string>jQuery('#login-username').val(),
169+
password: singleUseToken ? "" : <string>jQuery('#login-password').val(),
170+
language: 1,
171+
singleUseToken: singleUseToken || null
170172
}
171173

172-
ajax('login' + (singleUseToken ? ('?singleUseToken=' + singleUseToken) : ''), loginRequest, (response: LoginResponse) => {
174+
ajax('login', loginRequest, (response: LoginResponse) => {
173175

174176
if (!response.success) {
175177
jQuery('#login-message').html('Fehler: Benutzername und/oder Passwort ist falsch.');
176178
} else {
177179

180+
this.loggedInWithVidis = response.vidis_id_token != null;
181+
this.vidis_id_token = response.vidis_id_token;
182+
178183
PushClientManager.getInstance().open();
179184

180185
// We don't do this anymore for security reasons - see AjaxHelper.ts

‎src/client/main/Main.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Compiler, CompilerStatus } from "../compiler/Compiler.js";
44
import { Module } from "../compiler/parser/Module.js";
55
import { SemicolonAngel } from "../compiler/parser/SemicolonAngel.js";
66
import { DatabaseTool } from "../sqljs-worker/DatabaseTools.js";
7-
import { checkIfMousePresent, getCookieValue } from "../tools/HtmlTools.js";
7+
import { checkIfMousePresent, findGetParameter, getCookieValue } from "../tools/HtmlTools.js";
88
import { Workspace } from "../workspace/Workspace.js";
99
import { ActionManager } from "./gui/ActionManager.js";
1010
import { BottomDiv } from "./gui/BottomDiv.js";
@@ -145,15 +145,10 @@ export class Main implements MainBase {
145145

146146
this.login = new Login(this);
147147

148-
let singleUseToken1 = location.search.split('singleUseToken=')[1];
149-
if(singleUseToken1){
150-
setCookie("singleUseToken", singleUseToken1, 3);
151-
}
148+
let singleUseToken = findGetParameter("singleUseToken");
152149

153-
let singleUseToken: string | undefined = getCookieValue("singleUseToken");
154150

155151
if(singleUseToken){
156-
setCookie("singleUseToken", "", 0);
157152
this.login.initGUI();
158153
this.login.loginWithVidis(singleUseToken);
159154
} else {

‎src/client/main/gui/ResultsetPresenter.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,21 @@ export class ResultsetPresenter {
100100
}
101101

102102
exportCSV(){
103+
let quotationMark = '"';
104+
let separator = ",";
105+
if(!this.main.isEmbedded()){
106+
if((<Main>this.main).user.schule_id == 243){
107+
console.log("Using semicolon as separator and no quotation marks for CSV export, because school has id 243.");
108+
quotationMark = "";
109+
separator = ";";
110+
}
111+
}
112+
103113
let file: string = "";
104114
// file += table.columns.map(c => c.identifier).join("; ") + "\n";
105115
if(this.result){
106-
file += this.result.columns.map(c => `"${c}"`).join(",") + "\n";
107-
file += this.result.values.map(line => line.map(c => `"${c}"`).join(",")).join("\n");
116+
file += this.result.columns.map(c => `${quotationMark}${c}${quotationMark}`).join(separator) + "\n";
117+
file += this.result.values.map(line => line.map(c => `${quotationMark}${c}${quotationMark}`).join(separator)).join("\n");
108118
}
109119
downloadFile("\ufeff" + file, "results.csv", false);
110120

‎src/client/tools/HtmlTools.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,17 @@ export function getCookieValue(name: string): string | undefined
318318
if (match) {
319319
return match[2]
320320
}
321-
}
321+
}
322+
323+
export function findGetParameter(parameterName: string): string | null {
324+
var result: string | null = null,
325+
tmp: string[] = [];
326+
location.search
327+
.substring(1)
328+
.split("&")
329+
.forEach(function (item) {
330+
tmp = item.split("=");
331+
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
332+
});
333+
return result;
334+
}

0 commit comments

Comments
 (0)