Example #1
0
        public async void CheckIsAuthorized()
        {
            var token = Properties.Settings.Default["Token"].ToString();

            if (String.IsNullOrEmpty(token))
            {
                return;
            }

            //blocking btn Sign in
            IsActive = false;

            var tokenResponse = JsonConvert.DeserializeObject <TokenResponse>(token);

            Login      = tokenResponse.UserLogin;
            ErrorLabel = "Logining ...";

            _httpManager.Authorize(tokenResponse.Token);
            var response = await _httpManager.PostAsync <SocketTokenDTO>("api/Account/SocketToken");

            if (response.Error != null)
            {
                IsActive = true;

                if (response.Error.ErrorCode == 401)
                {
                    ErrorLabel = "You have to enter you password again";
                    Properties.Settings.Default["Token"] = "";
                    Properties.Settings.Default.Save();
                    return;
                }
                else
                {
                    ErrorLabel = response.Error.ErrorDescription;
                    return;
                }
            }

            Authorized(tokenResponse, response.Data.Id);
            //unblocking btn Sign in
            IsActive = true;
        }
Example #2
0
        public RoomsViewModel(TokenResponse tokenResponse)
        {
            _httpToken = tokenResponse;
            BuildImports();
            _httpManager.Authorize(_httpToken.Token);
            _fileManager.Authorize(_httpToken.Token);

            _fileManager.Failed += (m) => ShowNotification(m);

            AddRoomCommand         = new Command(obj => AddRoom());
            SendMessageCommand     = new Command(obj => SendMessage());
            SendFileCommand        = new Command(async obj => await SendFile());
            CopyOrDownloadCommand  = new Command(obj => CopyOrDownload());
            ParticipateRoomCommand = new Command(obj => Participate());
            LeaveRoomCommand       = new Command(obj => Leave());
            LogOutCommand          = new Command(obj => LogOut());

            LoadRooms();
        }
Example #3
0
 public void Authorize(string token)
 {
     _httpManager.Authorize(token);
 }