Skip to content

Commit

Permalink
Add auth check to LivestreamerService
Browse files Browse the repository at this point in the history
and implement ModalAuthRequiredComponent.
See #310
  • Loading branch information
bastimeyer committed Sep 14, 2016
1 parent 90c3dbf commit 84d5245
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ import ModalConfirmComponent from "components/modal/ModalConfirmComponent";
import ModalFirstrunComponent from "components/modal/ModalFirstrunComponent";
import ModalFooterComponent from "components/modal/ModalFooterComponent";
import ModalHeaderComponent from "components/modal/ModalHeaderComponent";
import ModalAuthRequiredComponent from "components/modal/ModalAuthRequiredComponent";
import ModalLivestreamerComponent from "components/modal/ModalLivestreamerComponent";
import ModalLogComponent from "components/modal/ModalLogComponent";
import ModalNewreleaseComponent from "components/modal/ModalNewreleaseComponent";
Expand Down Expand Up @@ -443,6 +444,7 @@ export default Application.create({
ModalFirstrunComponent,
ModalFooterComponent,
ModalHeaderComponent,
ModalAuthRequiredComponent,
ModalLivestreamerComponent,
ModalLogComponent,
ModalNewreleaseComponent,
Expand Down
19 changes: 19 additions & 0 deletions src/app/components/modal/ModalAuthRequiredComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ModalDialogComponent from "components/modal/ModalDialogComponent";
import layout from "templates/components/modal/ModalAuthRequiredComponent.hbs";


export default ModalDialogComponent.extend({
layout,

"class": "modal-auth-required",

goto: "goto",


actions: {
login() {
this.sendAction( "goto", "user.auth" );
this.send( "close" );
}
}
});
5 changes: 5 additions & 0 deletions src/app/services/LivestreamerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function setIfNotNull( objA, objB, key ) {


export default Service.extend( ChannelSettingsMixin, {
auth: service(),
chat: service(),
modal: service(),
settings: service(),
Expand All @@ -110,6 +111,10 @@ export default Service.extend( ChannelSettingsMixin, {


startStream( stream, quality ) {
if ( !get( this, "auth.session.isLoggedIn" ) ) {
return get( this, "modal" ).openModal( "authRequired" );
}

get( this, "modal" ).openModal( "livestreamer", this, {
error : null,
active: null,
Expand Down
12 changes: 12 additions & 0 deletions src/templates/components/modal/ModalAuthRequiredComponent.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div>
{{#modal-header}}
Authentication required
{{/modal-header}}
{{#modal-body}}
Please sign in to your Twitch.tv account to be able to launch streams.
{{/modal-body}}
{{#modal-footer}}
{{#form-button action="login" class="btn-success" icon="fa-sign-in"}}Sign in{{/form-button}}
{{#form-button action="close" class="btn-danger" icon="fa-times" }}Close{{/form-button}}
{{/modal-footer}}
</div>

0 comments on commit 84d5245

Please sign in to comment.