signup_ctrl.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. contextSrv.sidemenu = false;
  12. $scope.ctrl = this;
  13. $scope.formModel = {};
  14. var params = $location.search();
  15. $scope.formModel.orgName = params.email;
  16. $scope.formModel.email = params.email;
  17. $scope.formModel.username = params.email;
  18. $scope.formModel.code = params.code;
  19. $scope.verifyEmailEnabled = false;
  20. $scope.autoAssignOrg = false;
  21. $scope.navModel = {
  22. main: {
  23. icon: 'gicon gicon-branding',
  24. subTitle: 'Register your Grafana account',
  25. breadcrumbs: [
  26. { title: 'Login', uri: '/login' },
  27. { title: 'Sign Up' },
  28. ]
  29. }
  30. };
  31. backendSrv.get('/api/user/signup/options').then(options => {
  32. $scope.verifyEmailEnabled = options.verifyEmailEnabled;
  33. $scope.autoAssignOrg = options.autoAssignOrg;
  34. });
  35. }
  36. submit () {
  37. if (!this.$scope.signUpForm.$valid) {
  38. return;
  39. }
  40. this.backendSrv.post('/api/user/signup/step2', this.$scope.formModel).then(rsp => {
  41. if (rsp.code === 'redirect-to-select-org') {
  42. window.location.href = config.appSubUrl + '/profile/select-org?signup=1';
  43. } else {
  44. window.location.href = config.appSubUrl + '/';
  45. }
  46. });
  47. }
  48. }
  49. coreModule.controller('SignUpCtrl', SignUpCtrl);