public async Task <IActionResult> Register([FromBody] UserPasswordCredentials credentials) { if (credentials == null) { return(BadRequest()); } var user = new User { UserName = credentials.Email, Email = credentials.Email }; IActionResult result; var createResult = await _userManager.CreateAsync(user, credentials.Password); if (createResult.Succeeded) { await _signInManager.SignInAsync(user, isPersistent : false); result = Ok(); } else { result = Unauthorized(); } return(result); }
public TagExample() { //Make a new GraphDB instance var graphDB = new SonesGraphDB(); var credentials = new UserPasswordCredentials("User", "test"); //GraphDSServer = new GraphDS_Server(GraphDB, (ushort)9975, "User", "test", IPAddress.Any, PluginsAndParameters); GraphDSServer = new GraphDS_Server(graphDB, null); GraphDSServer.LogOn(credentials); //GraphDSServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any); //get a SecurityToken and an TransactionID SecToken = GraphDSServer.LogOn(credentials); TransationID = GraphDSServer.BeginTransaction(SecToken); }
public async Task <IActionResult> Login([FromBody] UserPasswordCredentials credentials) { if (credentials == null) { return(BadRequest()); } IActionResult result; var signInResult = await _signInManager.PasswordSignInAsync(credentials.Email, credentials.Password, false, false); if (signInResult.Succeeded) { Task <User> userTask = _userManager.FindByNameAsync(credentials.Email); var user = userTask.Result; result = Ok(user); } else { result = Unauthorized(); } return(result); }
public static void Main(string[] args) { var assemblyName = Assembly.GetExecutingAssembly().GetName(); Console.WriteLine("{0} Version {1}", assemblyName.Name, assemblyName.Version); #region Console arguments if (args.Length != 3) { Console.WriteLine("Please specify 'job type', 'job description' and 'job priority' as command line arguments!"); return; } var jobType = args[0]; var jobDesc = args[1]; var jobPriority = Convert.ToInt32(args[2]); #endregion #region Setting from App.config var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = Assembly.GetExecutingAssembly().Location + ".config" }; var configuration = ConfigurationManager.OpenMappedExeConfiguration( fileMap, ConfigurationUserLevel.None); var section = configuration.GetSection("Settings/Vault") as AppSettingsSection; if (section == null) { throw new ConfigurationErrorsException("Application Config file"); } var dataServer = section.Settings["DataServer"].Value; var fileServer = section.Settings["FileServer"].Value; var vault = section.Settings["Vault"].Value; var username = section.Settings["Username"].Value; var password = section.Settings["Password"].Value; #endregion try { Console.WriteLine("Vault '{0}', User '{1}'...", vault, username); var identities = new ServerIdentities { DataServer = dataServer, FileServer = fileServer }; var userPasswordCridentials = new UserPasswordCredentials( identities, vault, username, password, true); var wsm = new WebServiceManager(userPasswordCridentials); wsm.JobService.AddJob( jobType, jobDesc, new List <JobParam>().ToArray(), jobPriority); wsm.AuthService.SignOut(); Console.WriteLine("Added job '{0}' to job queue!", jobType); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); } }