develop #10
@ -27,6 +27,8 @@ namespace Klient.Droid
|
|||||||
public string savedName = "";
|
public string savedName = "";
|
||||||
public string savedSurname = "";
|
public string savedSurname = "";
|
||||||
public string savedEmail = "";
|
public string savedEmail = "";
|
||||||
|
private string userId = "";
|
||||||
|
private string userToken = "";
|
||||||
|
|
||||||
protected override void OnCreate(Bundle savedInstanceState)
|
protected override void OnCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@ -59,20 +61,20 @@ namespace Klient.Droid
|
|||||||
};
|
};
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(values);
|
var content = new FormUrlEncodedContent(values);
|
||||||
|
|
||||||
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
|
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/SignIn", content);
|
||||||
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
savedLogin = Login;
|
|
||||||
var jsonString = await response.Content.ReadAsStringAsync();
|
var jsonString = await response.Content.ReadAsStringAsync();
|
||||||
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
|
dynamic jsonObject = JsonConvert.DeserializeObject(jsonString);
|
||||||
SetContentView(Resource.Layout.ekranPoLogowaniu);
|
SetContentView(Resource.Layout.ekranPoLogowaniu);
|
||||||
|
savedLogin = jsonObject.user.login;
|
||||||
savedName = jsonObject.user.name;
|
savedName = jsonObject.user.name;
|
||||||
savedEmail = jsonObject.user.email;
|
savedEmail = jsonObject.user.email;
|
||||||
savedSurname = jsonObject.user.surname;
|
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>
|
var values = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
{ "id", userId },
|
||||||
{ "email", Email },
|
{ "email", Email },
|
||||||
{ "name", Name },
|
{ "name", Name },
|
||||||
{ "surname", Surname },
|
{ "surname", Surname },
|
||||||
{ "login", savedLogin }
|
{ "login", savedLogin }
|
||||||
};
|
};
|
||||||
var content = new FormUrlEncodedContent(values);
|
var content = new FormUrlEncodedContent(values);
|
||||||
|
|
||||||
var response = await client.PostAsync("http://10.0.2.2:5001/api/User/Update", content);
|
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)
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
FindViewById<TextView>(Resource.Id.NullValueProfile).Text = "Zapisano!";
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Serwer.Infrastructure.Services;
|
using Serwer.Infrastructure.Services;
|
||||||
using System;
|
using System;
|
||||||
@ -19,6 +20,7 @@ namespace Serwer.Api.Controllers
|
|||||||
_imageService = imageService;
|
_imageService = imageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
[HttpPost("Process")]
|
[HttpPost("Process")]
|
||||||
public async Task<IActionResult> Process([FromForm]IFormFile image)
|
public async Task<IActionResult> Process([FromForm]IFormFile image)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Serwer.Infrastructure.Services;
|
using Serwer.Infrastructure.Services;
|
||||||
using System;
|
using System;
|
||||||
@ -18,6 +19,7 @@ namespace Serwer.Api.Controllers
|
|||||||
_searchService = searchService;
|
_searchService = searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
[HttpGet("{query}")]
|
[HttpGet("{query}")]
|
||||||
public async Task<IActionResult> Search(string query)
|
public async Task<IActionResult> Search(string query)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ namespace Serwer.Infrastructure.Services
|
|||||||
throw new Exception("User login taken.");
|
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);
|
await _userRepository.UpdateAsync(newUser);
|
||||||
newUser = await _userRepository.GetAsync(user.Id);
|
newUser = await _userRepository.GetAsync(user.Id);
|
||||||
return _mapper.Map<UserDto>(newUser);
|
return _mapper.Map<UserDto>(newUser);
|
||||||
|
@ -13,6 +13,5 @@ namespace Serwer.Infrastructure.ViewModels
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Surname { get; set; }
|
public string Surname { get; set; }
|
||||||
public string Login { get; set; }
|
public string Login { get; set; }
|
||||||
public string Password { get; set; } = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user