<commit_before>// To parse this JSON data, do
//
//     final authenticationModel = authenticationModelFromJson(jsonString);

import 'dart:convert';

import 'package:hive/hive.dart';

part 'authentication.g.dart';

AuthenticationModel authenticationModelFromJson(String str) =>
    AuthenticationModel.fromJson(json.decode(str));

String authenticationModelToJson(AuthenticationModel data) =>
    json.encode(data.toJson());

@HiveType(typeId: 1)
class AuthenticationModel extends HiveObject {
  @HiveField(0)
  String accessToken;
  // Deprecated reserved field number - DO NOT REMOVE
  // @HiveField(1)
  // String refreshToken;
  @HiveField(2)
  String pid;
  @HiveField(3)
  String ucsdaffiliation;
  @HiveField(4)
  int expiration;

  AuthenticationModel({
    this.accessToken,
    this.pid,
    this.ucsdaffiliation,
    this.expiration,
  });

  factory AuthenticationModel.fromJson(Map<String, dynamic> json) {
    return AuthenticationModel(
      accessToken: json["access_token"] == null ? null : json["access_token"],
      pid: json["pid"] == null ? null : json["pid"],
      ucsdaffiliation:
          json["ucsdaffiliation"] == null ? null : json["ucsdaffiliation"],
      expiration: json["expiration"] == null ? 0 : json["expiration"],
    );
  }

  Map<String, dynamic> toJson() => {
        "access_token": accessToken == null ? null : accessToken,
        "pid": pid == null ? null : pid,
        "ucsdaffiliation": ucsdaffiliation == null ? null : ucsdaffiliation,
        "expiration": expiration == null ? null : expiration,
      };

  /// Checks if the token we got back is expired
  bool isLoggedIn(DateTime lastUpdated) {
    /// User has not logged in previously - isLoggedIn FALSE
    if (lastUpdated == null) {
      return false;
    }

    /// User has no expiration or accessToken - isLoggedIn FALSE
    if (expiration == null || accessToken == null) {
      return false;
    }

    /// User has expiration and accessToken
    if (DateTime.now()
        .isBefore(lastUpdated.add(Duration(seconds: expiration)))) {
      /// Current datetime < expiration datetime - isLoggedIn TRUE
      return true;
    } else {
      /// Current datetime > expiration datetime - isLoggedIn FALSE
      return false;
    }
  }
}<commit_msg>Update authentication model<commit_after>// To parse this JSON data, do
//
//     final authenticationModel = authenticationModelFromJson(jsonString);

import 'dart:convert';

import 'package:hive/hive.dart';

part 'authentication.g.dart';

AuthenticationModel authenticationModelFromJson(String str) =>
    AuthenticationModel.fromJson(json.decode(str));

String authenticationModelToJson(AuthenticationModel data) =>
    json.encode(data.toJson());

@HiveType(typeId: 1)
class AuthenticationModel extends HiveObject {
  @HiveField(0)
  String accessToken;
  // Deprecated reserved field number - DO NOT REMOVE
  // @HiveField(1)
  // String refreshToken;
  @HiveField(2)
  String pid;
  @HiveField(3)
  String ucsdaffiliation;
  @HiveField(4)
  int expiration;

  AuthenticationModel({
    this.accessToken,
    this.pid,
    this.ucsdaffiliation,
    this.expiration,
  });

  factory AuthenticationModel.fromJson(Map<String, dynamic> json) {
    return AuthenticationModel(
      accessToken: json["access_token"] == null ? null : json["access_token"],
      pid: json["pid"] == null ? null : json["pid"],
      ucsdaffiliation:
          json["ucsdaffiliation"] == null ? "" : json["ucsdaffiliation"],
      expiration: json["expiration"] == null ? 0 : json["expiration"],
    );
  }

  Map<String, dynamic> toJson() => {
        "access_token": accessToken == null ? null : accessToken,
        "pid": pid == null ? null : pid,
        "ucsdaffiliation": ucsdaffiliation == null ? "" : ucsdaffiliation,
        "expiration": expiration == null ? null : expiration,
      };

  /// Checks if the token we got back is expired
  bool isLoggedIn(DateTime lastUpdated) {
    /// User has not logged in previously - isLoggedIn FALSE
    if (lastUpdated == null) {
      return false;
    }

    /// User has no expiration or accessToken - isLoggedIn FALSE
    if (expiration == null || accessToken == null) {
      return false;
    }

    /// User has expiration and accessToken
    if (DateTime.now()
        .isBefore(lastUpdated.add(Duration(seconds: expiration)))) {
      /// Current datetime < expiration datetime - isLoggedIn TRUE
      return true;
    } else {
      /// Current datetime > expiration datetime - isLoggedIn FALSE
      return false;
    }
  }
}
{'fraction_non_alphanumeric': 0.12097130242825607, 'fraction_numerical': 0.0030905077262693157, 'mean_word_length': 3.246485473289597, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 15, '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': '7301996', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1325, 'n_words': 344}