From 80b2677cec2aad45f94a5d1764c814ea3ac41f46 Mon Sep 17 00:00:00 2001 From: Atsushi Nagase Date: Sat, 30 Jun 2018 10:41:08 +0900 Subject: [PATCH] Check status code --- CI2Go/View Controllers/BuildsViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CI2Go/View Controllers/BuildsViewController.swift b/CI2Go/View Controllers/BuildsViewController.swift index 6bb97f83..74edf6d3 100644 --- a/CI2Go/View Controllers/BuildsViewController.swift +++ b/CI2Go/View Controllers/BuildsViewController.swift @@ -160,10 +160,12 @@ class BuildsViewController: UITableViewController { } func loadUser() { - URLSession.shared.dataTask(endpoint: .me) { [weak self] (user, _, _, err) in + URLSession.shared.dataTask(endpoint: .me) { [weak self] (user, _, res, err) in guard let user = user else { Crashlytics.sharedInstance().recordError(err ?? APIError.noData) - self?.logout() + if let res = res as? HTTPURLResponse, res.statusCode == 401 { + self?.logout() + } return } self?.currentUser = user