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.

64 lines
2.1 KiB

  1. 'use strict';
  2. angular.module('app.login', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/login', {
  5. templateUrl: 'views/login/login.html',
  6. controller: 'LoginCtrl'
  7. });
  8. }])
  9. .controller('LoginCtrl', function($scope, $rootScope, $http, $routeParams, toastr) {
  10. $rootScope.server = ""
  11. $scope.proof = {
  12. publicKey: "",
  13. clear: "",
  14. question: "",
  15. answer: ""
  16. };
  17. $scope.getproof = function() {
  18. $http({
  19. url: urlapi + 'getproof',
  20. method: "POST",
  21. headers: {
  22. "Content-Type": undefined
  23. },
  24. data: $scope.proof
  25. })
  26. .then(function(data) {
  27. console.log("data: ");
  28. console.log(data.data);
  29. $scope.proof = data.data;
  30. },
  31. function(data) {
  32. console.log(data);
  33. toastr.error("error: bad darkID PublicKey")
  34. });
  35. };
  36. $scope.sendanswer = function() {
  37. $http({
  38. url: urlapi + 'answerproof',
  39. method: "POST",
  40. headers: {
  41. "Content-Type": undefined
  42. },
  43. data: $scope.proof
  44. })
  45. .then(function(data) {
  46. console.log("data: ");
  47. console.log(data.data);
  48. if(data.data=="fail\n") {
  49. toastr.error("Proof of darkID failed");
  50. }else{
  51. toastr.success("You are logged with darkID!");
  52. window.location="#!/main";
  53. }
  54. },
  55. function(data) {
  56. console.log(data);
  57. });
  58. };
  59. });