-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Address issue #323 and enable GHE Auth #491
Changes from 9 commits
de04389
2a89f3e
7d9b14c
049ef33
d9b5edf
ea32e9c
06cb4ca
8937c7d
f2f8b26
9ef3d05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ npm-debug.log | |
.tern-project | ||
yarn-error.log | ||
.vscode/ | ||
manifest.yml | ||
.imdone/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import { currentBackend } from '../backends/backend'; | ||
import { actions as notifActions } from 'redux-notifications'; | ||
|
||
const { notifSend } = notifActions; | ||
|
||
export const AUTH_REQUEST = 'AUTH_REQUEST'; | ||
export const AUTH_SUCCESS = 'AUTH_SUCCESS'; | ||
|
@@ -60,6 +63,11 @@ export function loginUser(credentials) { | |
dispatch(authenticate(user)); | ||
}) | ||
.catch((error) => { | ||
dispatch(notifSend({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍, this is a long-awaited change. |
||
message: `${ error.message }`, | ||
kind: 'warning', | ||
dismissAfter: 8000, | ||
})); | ||
dispatch(authError(error)); | ||
}); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,19 @@ export default class API { | |
return this.request("/user"); | ||
} | ||
|
||
isCollaborator(user) { | ||
return this.request('/user/repos').then((repos) => { | ||
let contributor = false | ||
for (const repo of repos) { | ||
if (repo.full_name === this.repo && repo.permissions.push) contributor = true; | ||
} | ||
return contributor; | ||
}).catch((error) => { | ||
console.error("Problem with response of /user/repos from GitHub"); | ||
throw error; | ||
}) | ||
} | ||
|
||
requestHeaders(headers = {}) { | ||
const baseHeader = { | ||
"Content-Type": "application/json", | ||
|
@@ -67,6 +80,9 @@ export default class API { | |
if (contentType && contentType.match(/json/)) { | ||
return this.parseJsonResponse(response); | ||
} | ||
if (responseStatus !== 200) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A generic request method like this should check the equivalent of if ((responseStatus >= 200) && (responseStatus <= 299)) { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Benaiah That's leftover from the collaborator check. I switched to a write permission check, so I'll just remove that actually. |
||
return responseStatus | ||
} | ||
return response.text(); | ||
}) | ||
.catch((error) => { | ||
|
@@ -241,7 +257,6 @@ export default class API { | |
persistFiles(entry, mediaFiles, options) { | ||
const uploadPromises = []; | ||
const files = mediaFiles.concat(entry); | ||
|
||
|
||
files.forEach((file) => { | ||
if (file.uploaded) { return; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.root { | ||
display: flex; | ||
flex-flow: column nowrap; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
|
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.
Today I learned you can't do full destructuring in an
import
call - I was going to suggestimport { actions: { notifSend } } from 'redux-notifications';
, but that syntax is only supported for assignment, not imports).