mirror of
https://github.com/mirego/accent.git
synced 2024-09-11 10:55:28 +03:00
Fix auth apollo link and big docker image size
This commit is contained in:
parent
2eae532580
commit
3d652a4a30
@ -26,7 +26,9 @@ webapp/node_modules
|
||||
webapp/tmp
|
||||
webapp/tests
|
||||
webapp/dist
|
||||
webapp/webapp-dist
|
||||
jipt/node_modules
|
||||
jipt/.cache
|
||||
jipt/dist
|
||||
jipt/webapp-dist
|
||||
cli
|
||||
|
@ -67,8 +67,8 @@ WORKDIR /opt/accent
|
||||
|
||||
# Copy the OTP binary and assets deps from the build step
|
||||
COPY --from=builder /opt/build .
|
||||
COPY --from=webapp-builder /opt/build .
|
||||
COPY --from=jipt-builder /opt/build .
|
||||
COPY --from=webapp-builder /opt/build/webapp-dist ./webapp-dist
|
||||
COPY --from=jipt-builder /opt/build/jipt-dist ./jipt-dist
|
||||
|
||||
RUN mv /opt/accent/webapp-dist /opt/accent/lib/accent-$APP_VERSION/priv/static/webapp && \
|
||||
mv /opt/accent/jipt-dist /opt/accent/lib/accent-$APP_VERSION/priv/static/jipt
|
||||
|
3
webapp/app/pods/components/login-footer/component.js
Normal file
3
webapp/app/pods/components/login-footer/component.js
Normal file
@ -0,0 +1,3 @@
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend();
|
5
webapp/app/pods/components/login-header/component.js
Normal file
5
webapp/app/pods/components/login-header/component.js
Normal file
@ -0,0 +1,5 @@
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
tagName: 'header'
|
||||
});
|
@ -41,17 +41,18 @@ const link = new BatchHttpLink({uri, batchInterval: 50, batchMax: 50});
|
||||
const absintheBatchLink = new ApolloLink((operation, forward) => {
|
||||
return forward(operation).map(response => response.payload);
|
||||
});
|
||||
const authLink = (session, router) => {
|
||||
const authLink = (session) => {
|
||||
return new ApolloLink((operation, forward) => {
|
||||
const token = session.credentials.token;
|
||||
if (!token) return router.transitionTo('login');
|
||||
|
||||
operation.setContext(({headers = {}}) => ({
|
||||
headers: {
|
||||
...headers,
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
}));
|
||||
if (token) {
|
||||
operation.setContext(({headers = {}}) => ({
|
||||
headers: {
|
||||
...headers,
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
return forward(operation);
|
||||
});
|
||||
@ -67,8 +68,8 @@ export default Service.extend({
|
||||
const client = new ApolloClient({
|
||||
uri,
|
||||
link: from([
|
||||
authLink(this.session),
|
||||
absintheBatchLink,
|
||||
authLink(this.session, this.router),
|
||||
link
|
||||
]),
|
||||
cache
|
||||
|
Loading…
Reference in New Issue
Block a user