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

Authentication + more #39

Merged
merged 18 commits into from
Jun 13, 2019
Merged

Authentication + more #39

merged 18 commits into from
Jun 13, 2019

Conversation

Donaldblanc
Copy link
Collaborator

Sorry guys I went a little off scrum with this commit but there are several issues in this commit.
[] this disables CORS for electron so we can make HTTP methods without issues
[] I have enabled React Dev tools with in electron, will need to show the team how to get that successfully running.
[] Created the header field
[] User can select to have authentication or No Authentication and will update state respectively
[] User can make a request without auth
[] User can make request with Auth, testing using yelp API, will show the team during stand up.
[] Remove the function declaration with in the loop of the fetch and created a helper function instead. It is not best practice to define functions within loops. Each iteration will create a new function in memory doing the exact same thing. For space complexity, made is a helper function and called that instead.
[] Remove the unnecessary quotes in the template literals in response component.

@Donaldblanc Donaldblanc added enhancement New feature or request user story Indicates a full user story (vs. an auxiliary task or sub-task) labels Jun 13, 2019
Copy link
Member

@conorsexton conorsexton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, I’m assuming some of this will change with UI updates over the next day or two. (Only real change request would be for #39 (comment))


if (isDev) {
BrowserWindow.addDevToolsExtension(
path.join(os.homedir(), './Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/3.6.0_0'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, it’d probably be best to move this elsewhere for production, but looks fine for now 👌

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<div>
<p>Headers</p>
<form>
<select name='header' id='headerTypeInput' multiple={false} value={header}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to just label this as "Authentication", and move the “none” option to the authType select (since the header we send auth info on should never change)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@conorsexton I made the label to reflect Authentication. I am not following the second request in regards to "none" and authType

// header info
const [headerType, setHeaderType] = useState('Authorization');
const [authType, setType] = useState('Bearer Token');
const [headerKey, setHeaderKey] = useState('');

const handleChange = (e) => {
const { name, value } = e.target;
if (name === 'method') setSelected(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mentioned, @Donaldblanc let’s plan to refactor this to a switch statement on a future iteration. Created an issue so we don’t forget (#40)

Copy link
Collaborator

@joepav joepav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at the comments, though! Two quick ones

};

const runTest = (link, sendingObj, testsClone, i) => {
const test = testsClone;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this duplicates testsClone-- now tests is just a reference to testsClone. Not a prob bc presumably it isn't modifying state considering it's called "clone", just worth noting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree its point to a reference in memory, but for cleanliness we I did not want to mutate directly from a parameter passed in.


fetch(uri, sendingObj)
.then(res => res.json())
.then(res => setData(res));
} else if (SourceOrDest === 'dest') {
const testsClone = [...tests];
const sendingObj = { method: selected, mode: 'cors' };
let counter = 0;
if (headerType !== 'NONE') sendingObj.headers = { [headerType]: headerKey };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pull both the
const sendingObj = { method: selected, mode: 'cors' };
and the
if (headerType !== 'NONE') sendingObj.headers = { [headerType]: headerKey };
outside of the if-statement. I wrote the first one, no problems on getting approved bc it works just fine, just noticed it now.

@@ -10,7 +10,7 @@ const ResponseComponent = (props) => {

return (
<div>
<p>{`${checkmark} ' - ' ${status}`}</p>
<p>{`${checkmark} - ${status}`}</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@conorsexton conorsexton merged commit 8bce671 into dev Jun 13, 2019
@conorsexton conorsexton deleted the authentication branch June 13, 2019 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request user story Indicates a full user story (vs. an auxiliary task or sub-task)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants