Beispiel #1
0
        public object TransferToken(string transferToken, Guid clientId, string secret)
        {
            if (transferToken.IsNullorEmpty())
            {
                throw new ArgumentException("Transfer Token inválido");
            }

            var token = accountInfraService.GetToken(transferToken, clientId, secret);

            if (token.IsNull())
            {
                throw new ArgumentException();
            }

            Account account = null;

            var applicationStore = applicationStoreRepository.GetByClientId(clientId);

            if (applicationStore.IsNull())
            {
                throw new ArgumentException("Transfer Token inválido - Aplicação não encontrada");
            }

            account = accPermissionService.Get(token.AccountCode, applicationStore);

            if (account.IsNull())
            {
                throw new ForbiddenException();
            }

            return(new
            {
                code = account.Code,
                email = account.Email,
                token = new
                {
                    access_token = token.AccessToken,
                    refresh_token = token.RefreshToken
                }
            });
        }