signupCtrl.js 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define([
  2. 'angular',
  3. 'config',
  4. ],
  5. function (angular, config) {
  6. 'use strict';
  7. var module = angular.module('grafana.controllers');
  8. module.controller('SignUpCtrl', function($scope, $location, contextSrv, backendSrv) {
  9. contextSrv.sidemenu = false;
  10. $scope.formModel = {};
  11. $scope.init = function() {
  12. var params = $location.search();
  13. $scope.formModel.orgName = params.email;
  14. $scope.formModel.email = params.email;
  15. $scope.formModel.username = params.email;
  16. $scope.formModel.code = params.code;
  17. };
  18. $scope.submit = function() {
  19. if (!$scope.signupForm.$valid) {
  20. return;
  21. }
  22. backendSrv.post('/api/user/signup/step2', $scope.formModel).then(function(rsp) {
  23. if (rsp.code === 'redirect-to-select-org') {
  24. window.location.href = config.appSubUrl + '/profile/select-org?signup=1';
  25. } else {
  26. window.location.href = config.appSubUrl + '/';
  27. }
  28. });
  29. };
  30. $scope.init();
  31. });
  32. });