Ejemplo n.º 1
0
        public IActionResult ResetAccount()
        {
            var token    = Request.Headers.FirstOrDefault(i => i.Key == "Authorization").Value;
            var userInfo = _authenticationService.GetUserInfo(token);
            var person   = _userValidationService.GetUser(userInfo.Sub);

            var result = _applicationManagerService.ResetAcccount(person);

            if (result.condition)
            {
                return(Ok());
            }
            return(StatusCode(500, result.message));
        }
Ejemplo n.º 2
0
        public IActionResult Get(string reference)
        {
            if (!string.IsNullOrEmpty(reference))
            {
                if (reference.ToLower() == "none")
                {
                    reference = string.Empty;
                }
            }

            var userInfo = _authenticationService.GetUserInfo(Request.Token());

            if (!_userValidationService.IsNewUser(userInfo.Sub, reference))
            {
                _userValidationService.CreateAttendee(userInfo, reference);
            }

            var result = _userValidationService.GetUser(userInfo.Sub);

            return(Ok(result));
        }
Ejemplo n.º 3
0
        public AuthenticationHelper(string token,
                                    IAuthenticationService _authenticationService,
                                    IInstanceRepository instanceRepository,
                                    IApplicationSetting applicationSetting,
                                    IUserValidationService userValidationService)
        {
            var userInfo = _authenticationService.GetUserInfo(token);

            this.UserInfo = userValidationService.GetUser(userInfo.Sub);

            if (string.IsNullOrEmpty(this.UserInfo.Related))// this will use the defasult user instance id, this is if the user is a owner
            {
                this.Instance = instanceRepository.GetByUsername(this.UserInfo.InstanceId,
                                                                 applicationSetting.CreateConnectionString(
                                                                     applicationSetting.Server,
                                                                     applicationSetting.Catalogue,
                                                                     applicationSetting.Username,
                                                                     applicationSetting.Password)).Instance;
            }
            else
            {
                if (this.UserInfo.Related.Contains("&"))
                {
                    string relatedstring = this.UserInfo.Related;
                    if (this.UserInfo.Related.Contains('|'))
                    {
                        relatedstring = this.UserInfo.Related.TupleSplit().value;
                    }

                    (string instanceId, string meetingId)relatedInstance = relatedstring.SplitToList("&", ";").FirstOrDefault(); // This is to be updated to allow multiple
                    this.Instance = instanceRepository.GetByUsername(relatedInstance.instanceId,
                                                                     applicationSetting.CreateConnectionString(
                                                                         applicationSetting.Server,
                                                                         applicationSetting.Catalogue,
                                                                         applicationSetting.Username,
                                                                         applicationSetting.Password)).Instance;
                }
                else
                {
                    this.Instance = instanceRepository.GetByUsername(this.UserInfo.Name,
                                                                     applicationSetting.CreateConnectionString(
                                                                         applicationSetting.Server,
                                                                         applicationSetting.Catalogue,
                                                                         applicationSetting.Username,
                                                                         applicationSetting.Password)).Instance;
                }
            }
            if (this.Instance == null)
            {
                this.ConnectionString = applicationSetting.CreateConnectionString(
                    applicationSetting.Server,
                    applicationSetting.Catalogue,
                    applicationSetting.Username,
                    applicationSetting.Password);
            }
            else
            {
                this.ConnectionString = applicationSetting.CreateConnectionString(
                    applicationSetting.Server,
                    applicationSetting.Catalogue,
                    this.Instance.Username,
                    this.Instance.Password);
            }
        }