-
Notifications
You must be signed in to change notification settings - Fork 12
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
WIP: json session store #29
base: master
Are you sure you want to change the base?
Conversation
It's always better to have a human-readable JSON file than an unreadable DAT one containing bytes. You can see what the session file contains, what it is all about. Also, it prevents the file from getting corrupted. Happened to me a few times in the past using FileSessionStore, had to delete the session file and reconnect/auth. And it's just way better in general for storing data. For example, I currently store a lot of sessions in a SQL database, and doing it with bytes would have been a pain. JSON session file is just better in general.
@@ -160,17 +239,17 @@ public static Session FromBytes(byte[] buffer, ISessionStore store, string sessi | |||
|
|||
var isAuthExsist = reader.ReadInt32() == 1; | |||
int sessionExpires = 0; | |||
TLUser TLUser = null; | |||
int userId = default; | |||
if (isAuthExsist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol that typo is not in my commit :P
if (isAuthExsist) | ||
{ | ||
sessionExpires = reader.ReadInt32(); | ||
TLUser = (TLUser)ObjectUtils.DeserializeObject(reader); | ||
userId = (int)ObjectUtils.DeserializeObject (reader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userId = reader.ReadInt32();
{ | ||
writer.Write(1); | ||
writer.Write(SessionExpires); | ||
ObjectUtils.SerializeObject(TLUser, writer); | ||
ObjectUtils.SerializeObject (UserId, writer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writer.write(UserId);
} | ||
public bool AuthenticatedSuccessfully { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we don't have to save UserId at all because we can just run GetSelfUser and If we're not authenticated we get an error
No description provided.