Browse Source

Only show logout and warning if there is something stored.

pull/28/head
Simon Eisenmann 11 years ago
parent
commit
9a1b3c9548
  1. 1
      static/js/controllers/mediastreamcontroller.js
  2. 2
      static/js/directives/settings.js
  3. 4
      static/partials/settings.html

1
static/js/controllers/mediastreamcontroller.js

@ -394,6 +394,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
// Check if we can load a user. // Check if we can load a user.
var login = mediaStream.users.load(); var login = mediaStream.users.load();
if (login !== null) { if (login !== null) {
$scope.loadedUserlogin = true;
console.log("Trying to authorize with stored credentials ..."); console.log("Trying to authorize with stored credentials ...");
mediaStream.users.authorize(login, function(data) { mediaStream.users.authorize(login, function(data) {
console.info("Retrieved nonce - authenticating as user:", data.userid); console.info("Retrieved nonce - authenticating as user:", data.userid);

2
static/js/directives/settings.js

@ -135,6 +135,8 @@ define(['underscore', 'text!partials/settings.html'], function(_, template) {
if (data.nonce) { if (data.nonce) {
// If the server provided us a nonce, we can do everthing on our own. // If the server provided us a nonce, we can do everthing on our own.
mediaStream.users.store(data); mediaStream.users.store(data);
$scope.loadedUserlogin = true;
safeApply($scope);
// Directly authenticate ourselves with the provided nonce. // Directly authenticate ourselves with the provided nonce.
mediaStream.api.requestAuthentication(data.userid, data.nonce); mediaStream.api.requestAuthentication(data.userid, data.nonce);
delete data.nonce; delete data.nonce;

4
static/partials/settings.html

@ -34,7 +34,7 @@
</label> </label>
<span class="help-block" ng-if="!userid && withUsersRegistration">{{_('Only register an ID if this is your private browser.')}}</span> <span class="help-block" ng-if="!userid && withUsersRegistration">{{_('Only register an ID if this is your private browser.')}}</span>
<pre class="small" ng-if="userid">{{userid}}</pre> <pre class="small" ng-if="userid">{{userid}}</pre>
<label ng-if="userid"> <label ng-if="userid && loadedUserlogin">
<a class="btn btn-small btn-default" ng-click="forgetUserid()">{{_('Log out')}}</a> <a class="btn btn-small btn-default" ng-click="forgetUserid()">{{_('Log out')}}</a>
</label> </label>
</div> </div>
@ -145,7 +145,7 @@
<label> <label>
<input type="checkbox" ng-model="rememberSettings"> {{_('Remember settings')}} <input type="checkbox" ng-model="rememberSettings"> {{_('Remember settings')}}
</label> </label>
<p class="text-warning" style="margin-top:4px" ng-show="userid &&!rememberSettings"><strong>{{_('Your ID will still be kept - press the log out button above to delete the ID.')}}</strong></p> <p class="text-warning" style="margin-top:4px" ng-show="userid &&!rememberSettings && loadedUserlogin"><strong>{{_('Your ID will still be kept - press the log out button above to delete the ID.')}}</strong></p>
</div> </div>
<a ng-click="layout.settings=false" class="btn btn-default">{{_('Close')}}</a> <a ng-click="layout.settings=false" class="btn btn-default">{{_('Close')}}</a>
</div> </div>

Loading…
Cancel
Save