develop #10

Merged
s426229 merged 80 commits from develop into master 2021-01-27 18:32:19 +01:00
5 changed files with 20 additions and 11 deletions
Showing only changes of commit da4287973e - Show all commits

View File

@ -27,6 +27,8 @@ namespace Klient.Droid
public string savedName = "";
public string savedSurname = "";
public string savedEmail = "";
private string userId = "";
private string userToken = "";
protected override void OnCreate(Bundle savedInstanceState)
{
@ -59,20 +61,20 @@ namespace Klient.Droid
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
if (response.StatusCode == HttpStatusCode.OK)
{
savedLogin = Login;
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
SetContentView(Resource.Layout.ekranPoLogowaniu);
savedLogin = jsonObject.user.login;
savedName = jsonObject.user.name;
savedEmail = jsonObject.user.email;
savedSurname = jsonObject.user.surname;
userId = jsonObject.user.id;
userToken = jsonObject.jwt.token;
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", userToken);
}
}
@ -211,20 +213,24 @@ namespace Klient.Droid
}
var values = new Dictionary<string, string>
{
{ "id", userId },
{ "email", Email },
{ "name", Name },
{ "surname", Surname },
{ "login", savedLogin }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Update", content);
var responseString = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK)
{
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Zapisano!";
var jsonString = await response.Content.ReadAsStringAsync();
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
savedLogin = jsonObject.login;
savedName = jsonObject.name;
savedEmail = jsonObject.email;
savedSurname = jsonObject.surname;
}
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
@ -19,6 +20,7 @@ namespace Serwer.Api.Controllers
_imageService = imageService;
}
[Authorize]
[HttpPost("Process")]
public async Task<IActionResult> Process([FromForm]IFormFile image)
{

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
@ -18,6 +19,7 @@ namespace Serwer.Api.Controllers
_searchService = searchService;
}
[Authorize]
[HttpGet("{query}")]
public async Task<IActionResult> Search(string query)
{

View File

@ -69,7 +69,7 @@ namespace Serwer.Infrastructure.Services
throw new Exception("User login taken.");
}
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, userModel.Password);
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, user.Password);
await _userRepository.UpdateAsync(newUser);
newUser = await _userRepository.GetAsync(user.Id);
return _mapper.Map<UserDto>(newUser);

View File

@ -13,6 +13,5 @@ namespace Serwer.Infrastructure.ViewModels
public string Name { get; set; }
public string Surname { get; set; }
public string Login { get; set; }
public string Password { get; set; } = null;
}
}