Archived
Prohibited WebView in LoginViewController from visiting a domain other than the school's login page, updated link for fetching substitutions
This commit is contained in:
@@ -37,7 +37,7 @@ class DataFetcher {
|
|||||||
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
||||||
DispatchQueue(label: "work-queue").async {
|
DispatchQueue(label: "work-queue").async {
|
||||||
let foodUrl = "https://djd4rkn355.github.io/food.html"
|
let foodUrl = "https://djd4rkn355.github.io/food.html"
|
||||||
let url = "https://djd4rkn355.github.io/subst.html"
|
let url = "https://djd4rkn355.github.io/avh_substitutions.html"
|
||||||
Alamofire.request(url).responseString { response in
|
Alamofire.request(url).responseString { response in
|
||||||
if let html = response.result.value {
|
if let html = response.result.value {
|
||||||
Alamofire.request(foodUrl).responseString { response in
|
Alamofire.request(foodUrl).responseString { response in
|
||||||
|
|||||||
@@ -13,15 +13,24 @@ class LoginViewController: UIViewController, WKNavigationDelegate {
|
|||||||
|
|
||||||
@IBOutlet weak var webView: WKWebView!
|
@IBOutlet weak var webView: WKWebView!
|
||||||
let prefs = UserDefaults.standard
|
let prefs = UserDefaults.standard
|
||||||
|
let request = URLRequest(url: URL(string: "https://307.joomla.schule.bremen.de/index.php/component/users/#top")!)
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
let request = URLRequest(url: URL(string: "https://307.joomla.schule.bremen.de/index.php/component/users/#top")!)
|
self.reloadLoginPage(in: webView)
|
||||||
self.webView.load(request)
|
|
||||||
self.webView.navigationDelegate = self
|
self.webView.navigationDelegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
||||||
|
let page = webView.url?.absoluteString
|
||||||
|
if (page != "https://307.joomla.schule.bremen.de/index.php/component/users/profile?Itemid=171"
|
||||||
|
&& page != "https://307.joomla.schule.bremen.de/index.php/component/users/#top"
|
||||||
|
&& page != "https://307.joomla.schule.bremen.de/index.php/component/users/?task=user.login&Itemid=171") {
|
||||||
|
self.reloadLoginPage(in: webView)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
self.webView.configuration.websiteDataStore.httpCookieStore.getAllCookies { cookies in
|
self.webView.configuration.websiteDataStore.httpCookieStore.getAllCookies { cookies in
|
||||||
for cookie in cookies {
|
for cookie in cookies {
|
||||||
@@ -32,6 +41,10 @@ class LoginViewController: UIViewController, WKNavigationDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func reloadLoginPage(in webView: WKWebView) {
|
||||||
|
self.webView.load(request)
|
||||||
|
}
|
||||||
|
|
||||||
private func success() {
|
private func success() {
|
||||||
self.prefs.set(true, forKey: "logged_in")
|
self.prefs.set(true, forKey: "logged_in")
|
||||||
if let s = storyboard?.instantiateViewController(withIdentifier: "FirstTime") as? UINavigationController {
|
if let s = storyboard?.instantiateViewController(withIdentifier: "FirstTime") as? UINavigationController {
|
||||||
|
|||||||
Reference in New Issue
Block a user