-
Notifications
You must be signed in to change notification settings - Fork 18
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
AWS SES implementation #201
AWS SES implementation #201
Conversation
Please fix warnings from linters |
@@ -9,10 +9,10 @@ export interface HttpRequestOptions<T = unknown> { | |||
} | |||
|
|||
export class HttpError { | |||
code: number; | |||
code: string; |
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.
Shouldn't these always be numbers?
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.
No, errorCode
is a string, numericErrorCode
is a number. Example:
var err = new ErrorResponse()
{
ErrorCode = "ut4masterserver.accountpendingactivation",
ErrorMessage = accountNotActiveException.Message,
MessageVars = Array.Empty<string>(),
NumericErrorCode = 401
};
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.
Ah, right. The http status code from the fetch api will be a number though, so we should either change the http service to pull numeric error code or change it so that it makes the http error code a string. Otherwise you'll never be able to correctly compare it because typescript will think it has a string when it has a number.
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.
I see how you're using it now, I will make some changes to it, don't worry about it
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.
We could use numericErrorCode
instead, but then you would have "magic" numbers on the frontend. I think string representation of an error is better for understanding.
And when I say errorCode
, I am not referring to the HTTP response code (400 or similar) which is a number.
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.
Http status codes are hardly magic numbers, they are well defined, and easily enumerated. And we still have that numeric case, when the error response isn't of type ErrorResponse. I will make it accept either case.
Renamed Activation to ActivateAccount
@Saibamen Where do you see warnings? |
|
||
if (email?.toString() === '' || guid?.toString() === '') { | ||
if (accountId?.toString() === '' || guid?.toString() === '') { |
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.
You don't need to toString and compare to empty string here, just !accountId?.length will work. The query string vars are either string or string[] or null, so a length of 0 is empty string or empty array. This code actually wouldn't work if they were null or undefined, because undefined !== ''
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.
At first, it was giving me LocationQueryValue as variable type, that is why I had to do toString, but now when I check, destructuring an object to a new variable actually does converting to string.
Example: /Login?activationLinkSent=done
Code:
const { activationLinkSent: qActivationLinkSent } = route.query;
console.log(
'activationLinkSent:',
activationLinkSent,
qActivationLinkSent,
qActivationLinkSent?.length
);
Output: activationLinkSent: RefImpl {__v_isShallow: true, dep: Set(1), __v_isRef: true, _rawValue: false, _value: false} done 4
Example 2: /Login?activationLinkSent=
Output: activationLinkSent: RefImpl {__v_isShallow: true, dep: Set(1), __v_isRef: true, _rawValue: false, _value: false} 0
Example 3: /Login?activationLinkSent
Output: activationLinkSent: RefImpl {__v_isShallow: true, dep: Set(1), __v_isRef: true, _rawValue: false, _value: false} null undefined
I will see what kind of check will cover all cases.
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.
LocationQueryVariable is a type defined as string | string[] | null
The code I gave you covers all cases.
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.
You're getting that RefImpl because you're outputting activationLinkSent rather than activationLinkSent.value.
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.
The check should be !qActivationLinkSent?.length because that is just looking for a falsey value. Undefined is falsey and so is 0.
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.
But again, don't worry about it, I will fix it in the feature branch, you can merge this and I will pull and fix, it is easier to show you than explain in comments
There are warnings about non-null assertion. I commented how they can be fixed. The warnings are correct, too, it is asserting not null when it isn't necessarily true. |
This is good to merge to the feature branch, I will fix up the commented areas. |
This PR implements the following:
Related: #139