<commit_before>import Foundation
import KeychainAccess

class User: NSObject, NSCoding {

    let id: String
    let username: String
    var password: String?

    let keychain = Keychain(service: NSBundle.mainBundle().bundleIdentifier!)

    var authToken: String? {
        didSet {
            if LoginService.storePassword {
                // Store to keychain
                if authToken != nil {
                    do {
                        try keychain.set(authToken!, key: "authToken")
                    } catch {
                        NSLog("Failed to set authToken")
                    }
                } else {
                    self.clearToken()
                }
            }
        }
    }

    func clearToken() {
        do {
            try keychain.remove("authToken")
        } catch {
            NSLog("Failed to clear authToken")
        }
    }

    init(id: String, username: String) {
        self.id = id
        self.username = username
    }

    required init(coder aDecoder: NSCoder) {
        if let username = aDecoder.decodeObjectForKey("username") as? String,
            let id = aDecoder.decodeObjectForKey("id") as? String {
                self.id = id
                self.username = username

        } else {
            self.id = ""
            self.username = ""
        }


        do {
            if let authToken = try keychain.get("authToken") {
                self.authToken = authToken
            }
        } catch {
            NSLog("Failed to set authToken")
        }
    }

    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(self.id, forKey: "id")
        aCoder.encodeObject(self.username, forKey: "username")
        if let authToken = self.authToken {
            aCoder.encodeObject(authToken, forKey: "authToken")<commit_msg>Ensure user object can be accessed.<commit_after>import Foundation
import KeychainAccess

public class User: NSObject, NSCoding {

    public let id: String
    let username: String
    var password: String?

    let keychain = Keychain(service: NSBundle.mainBundle().bundleIdentifier!)

    var authToken: String? {
        didSet {
            if LoginService.storePassword {
                // Store to keychain
                if authToken != nil {
                    do {
                        try keychain.set(authToken!, key: "authToken")
                    } catch {
                        NSLog("Failed to set authToken")
                    }
                } else {
                    self.clearToken()
                }
            }
        }
    }

    func clearToken() {
        do {
            try keychain.remove("authToken")
        } catch {
            NSLog("Failed to clear authToken")
        }
    }

    init(id: String, username: String) {
        self.id = id
        self.username = username
    }

    public required init(coder aDecoder: NSCoder) {
        if let username = aDecoder.decodeObjectForKey("username") as? String,
            let id = aDecoder.decodeObjectForKey("id") as? String {
                self.id = id
                self.username = username

        } else {
            self.id = ""
            self.username = ""
        }


        do {
            if let authToken = try keychain.get("authToken") {
                self.authToken = authToken
            }
        } catch {
            NSLog("Failed to set authToken")
        }
    }

    public func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(self.id, forKey: "id")
        aCoder.encodeObject(self.username, forKey: "username")
        if let authToken = self.authToken {
            aCoder.encodeObject(authToken, forKey: "authToken")
{'fraction_non_alphanumeric': 0.09054054054054055, 'fraction_numerical': 0.0, 'mean_word_length': 1.4396835860250494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2235421', 'n_tokens_mistral': 1005, 'n_tokens_neox': 957, 'n_words': 236}