A simple file sharing site with an easy to use API and online panel.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
954B

  1. const angular = require('angular');
  2. angular.module('LoginComp', ['AuthSvc']).component('loginComponent', {
  3. templateUrl: '/views/shimapan/login-form.html',
  4. controller: ['$scope', '$window', '$timeout', 'AuthService', function($scope, $window, $timeout, AuthService) {
  5. $scope.flash = classname => {
  6. $scope.$apply(() => $scope[classname] = true);
  7. $timeout(() => $scope[classname] = false, 820);
  8. };
  9. $scope.error = false;
  10. $scope.login = async () => {
  11. try {
  12. await AuthService.login($scope.username, $scope.password);
  13. $window.location.href = '/home';
  14. } catch(err) {
  15. if (err === 'limited')
  16. $scope.flash('warn');
  17. else if (err === 'unauthorized')
  18. $scope.flash('error');
  19. else
  20. $scope.flash('error');
  21. }
  22. };
  23. }]
  24. });