public async Task <RegistrationModel> OnRegistration(RegistrationInputModel input) { RegistrationModel result = new RegistrationModel(); if (string.IsNullOrEmpty(input.username) || string.IsNullOrEmpty(input.firstName) || string.IsNullOrEmpty(input.lastName) || string.IsNullOrEmpty(input.password)) { result.GenerateError("Неки од података фале!"); return(result); } // check if there is account with same username var db = ARDirect.Instance; if (await ARDirect.Instance.Query <ClientDM>().Where("username={0}", input.username).CountAsync() > 0) { result.GenerateError("Корисничко име је заузето. Одаберите неко друго!"); return(result); } ClientDM client = new ClientDM(db) { username = input.username, password = DirectPassword.Hash(input.password), firstName = input.firstName, lastName = input.lastName }; await client.InsertAsync(); this.Notify(Sockets.Dashboard.Models.DashboardModel.FunctionTypes.notifySuccess, $"Нови корисник се регистровао: '${client.username}'!"); return(result); }
public ActionResult CreateUser(string username, string password) { ClientDM client = new ClientDM() { username = username, password = DirectPassword.Hash(password), firstName = "firstname", lastName = "lastname" }; client.InsertAsync(); client.WaitIDExplicit(10); return(this.Content("Userid: " + client.ID.Value)); }
public async Task <LoginModel> Index(LoginInputModel input) { var result = new LoginModel(); if (string.IsNullOrEmpty(input.username) || string.IsNullOrEmpty(input.password)) { result.GenerateError("Неки од података фале!"); return(result); } ClientDM client = await ARDirect.Instance.Query <ClientDM>().Where("username={0}", input.username).LoadSingleAsync(); if (client == null) { result.GenerateError("Не постоји налог са корисничким именом!"); return(result); } if (!DirectPassword.Verify(input.password, client.password)) { result.GenerateError("Погрешна шифра!"); return(result); } ClientSessionDM session = new ClientSessionDM() { clientid = client.ID.Value }; await session.InsertAsync(); session.WaitID(3); result.clientID = client.ID.Value; result.session = session.clientSessionGuid.ToString(); result.username = client.username; result.firstName = client.firstName; result.lastName = client.lastName; result.profilePic = client.profilePic; this.Notify(Sockets.Dashboard.Models.DashboardModel.FunctionTypes.notifySuccess, $"Korisnik '${client.username}' se ulogovao!"); AndroidSocketManager.Current.Send(FitAR.Sockets.Models.AndroidSocketMessage.Construct("text", "green", new FitAR.Sockets.Models.AndroidSocketTextMessage() { text = $"Korisnik '${client.username}' se ulogovao!" })); return(result); }