Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessToken expiration time #136

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions source/TuviAuthProtonLib/SessionData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2023 Eppie(https://eppie.io)
// Copyright 2024 Eppie(https://eppie.io)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;

namespace Tuvi.Auth.Proton
{
Expand All @@ -25,25 +26,29 @@ public struct SessionData : IEquatable<SessionData>
public string Uid { get; set; }
public string AccessToken { get; set; }
public string TokenType { get; set; }
public long ExpirationTime { get; set; }

public bool Equals(SessionData other)
public override bool Equals(object obj)
{
return string.Equals(Uid, other.Uid, StringComparison.Ordinal) &&
string.Equals(TokenType, other.TokenType, StringComparison.Ordinal) &&
string.Equals(AccessToken, other.AccessToken, StringComparison.Ordinal);
return obj is SessionData data && Equals(data);
}

public override bool Equals(object obj)
public override int GetHashCode()
{
if (obj is SessionData sessionData)
return Equals(sessionData);

return false;
int hashCode = 1002824224;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Uid);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(AccessToken);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(TokenType);
hashCode = hashCode * -1521134295 + ExpirationTime.GetHashCode();
return hashCode;
}

public override int GetHashCode()
public bool Equals(SessionData other)
{
return (Uid, TokenType, AccessToken).GetHashCode();
return Uid == other.Uid &&
AccessToken == other.AccessToken &&
TokenType == other.TokenType &&
ExpirationTime == other.ExpirationTime;
}

public static bool operator ==(SessionData left, SessionData right)
Expand Down
Loading