Skip to content

Commit

Permalink
chore: redirect from mobile launch url
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Jul 14, 2024
1 parent bc522ef commit 307786c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/features/autologin/content-script.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { MOODLE_LOGIN_URL } from '@/shared/config/moodle'
import { MOODLE_DASHBOARD_URL, MOODLE_LOGIN_URL, MOODLE_MOBILE_LAUNCH_URL } from '@/shared/config/moodle'
import { sendMessage } from '@/shared/messages'

export function requestAutologinIfNeeded() {
if (window.location.href.startsWith(MOODLE_LOGIN_URL)) {
sendMessage('REQUEST_AUTOLOGIN')
}
else if (window.location.href.startsWith(MOODLE_MOBILE_LAUNCH_URL)) {
window.location.href = MOODLE_DASHBOARD_URL
}
else if (document.body.classList.contains('notloggedin')) {
sendMessage('REQUEST_AUTOLOGIN')
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/config/moodle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export const MOODLE_URL = 'https://moodle.innopolis.university'
export const MOODLE_WS_URL = `${MOODLE_URL}/webservice/rest/server.php`
export const MOODLE_MOBILE_LAUNCH_URL = `${MOODLE_URL}/admin/tool/mobile/launch.php`
export const MOODLE_LOGIN_URL = `${MOODLE_URL}/login/index.php`
export const MOODLE_DASHBOARD_URL = `${MOODLE_URL}/my/`
export const MOODLE_GRADES_URL = (id: number) => `${MOODLE_URL}/grade/report/user/index.php?id=${id}`

0 comments on commit 307786c

Please sign in to comment.