signup_ctrl.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ///<reference path="../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import coreModule from '../core_module';
  4. export class SignUpCtrl {
  5. /** @ngInject */
  6. constructor(
  7. private $scope: any,
  8. private backendSrv: any,
  9. $location: any,
  10. contextSrv: any
  11. ) {
  12. contextSrv.sidemenu = false;
  13. $scope.ctrl = this;
  14. $scope.formModel = {};
  15. var params = $location.search();
  16. $scope.formModel.orgName = params.email;
  17. $scope.formModel.email = params.email;
  18. $scope.formModel.username = params.email;
  19. $scope.formModel.code = params.code;
  20. $scope.verifyEmailEnabled = false;
  21. $scope.autoAssignOrg = false;
  22. $scope.navModel = {
  23. main: {
  24. icon: 'gicon gicon-branding',
  25. subTitle: 'Register your Grafana account',
  26. breadcrumbs: [{ title: 'Login', url: '/login' }, { title: 'Sign Up' }],
  27. },
  28. };
  29. backendSrv.get('/api/user/signup/options').then(options => {
  30. $scope.verifyEmailEnabled = options.verifyEmailEnabled;
  31. $scope.autoAssignOrg = options.autoAssignOrg;
  32. });
  33. }
  34. submit() {
  35. if (!this.$scope.signUpForm.$valid) {
  36. return;
  37. }
  38. this.backendSrv
  39. .post('/api/user/signup/step2', this.$scope.formModel)
  40. .then(rsp => {
  41. if (rsp.code === 'redirect-to-select-org') {
  42. window.location.href =
  43. config.appSubUrl + '/profile/select-org?signup=1';
  44. } else {
  45. window.location.href = config.appSubUrl + '/';
  46. }
  47. });
  48. }
  49. }
  50. coreModule.controller('SignUpCtrl', SignUpCtrl);