示例#1
0
        public async Task <IWebUser> Login([FromBody] AccountLogin creds)
        {
            if (ModelState.IsValid)
            {
                IWebUser user = _manager.Login(creds);
                if (user != null)
                {
                    await SetUserSession(user);

                    return(user);
                }
            }
            throw new Exception("Invalid Credentials");
        }
示例#2
0
        private async Task <IWebUser> SetUserSession(IWebUser user)
        {
            await HttpContext.SignInAsync(user.GetPrincipal());

            return(user);
        }
 public SocketUser(IWebUser user, ChannelsManager cm, WebSocket socket)
 {
     Socket             = socket;
     User               = user;
     SubscribedChannels = cm.GetSubscribedChannels(user.Id);
 }
示例#4
0
		///	<summary> 
		///		This method copy's each database field which is in the <paramref name="includedColumns"/> 
		///		from the <paramref name="source"/> interface to this data row.
		/// </summary>
		public void Copy_From_But_TakeOnly(IWebUser source, params string[] includedColumns)
		{
			if (includedColumns.Contains(WebUsersTable.IdCol)) this.Id = source.Id;
			if (includedColumns.Contains(WebUsersTable.IsAdminCol)) this.IsAdmin = source.IsAdmin;
			if (includedColumns.Contains(WebUsersTable.NameCol)) this.Name = source.Name;
			if (includedColumns.Contains(WebUsersTable.PasswordCol)) this.Password = source.Password;
			if (includedColumns.Contains(WebUsersTable.EMailCol)) this.EMail = source.EMail;
			if (includedColumns.Contains(WebUsersTable.VornameCol)) this.Vorname = source.Vorname;
			if (includedColumns.Contains(WebUsersTable.NachnameCol)) this.Nachname = source.Nachname;
			if (includedColumns.Contains(WebUsersTable.LastLoginCol)) this.LastLogin = source.LastLogin;
			if (includedColumns.Contains(WebUsersTable.CreationTimeCol)) this.CreationTime = source.CreationTime;
		}
示例#5
0
		///	<summary> This method copy's each database field from the <paramref name="source"/> interface to this data row.</summary>
		public void Copy_From(IWebUser source, bool includePrimaryKey = false)
		{
			if (includePrimaryKey) this.Id = source.Id;
			this.IsAdmin = source.IsAdmin;
			this.Name = source.Name;
			this.Password = source.Password;
			this.EMail = source.EMail;
			this.Vorname = source.Vorname;
			this.Nachname = source.Nachname;
			this.LastLogin = source.LastLogin;
			this.CreationTime = source.CreationTime;
		}
示例#6
0
		///	<summary> This method copy's each database field into the <paramref name="target"/> interface. </summary>
		public void Copy_To(IWebUser target, bool includePrimaryKey = false)
		{
			if (includePrimaryKey) target.Id = this.Id;
			target.IsAdmin = this.IsAdmin;
			target.Name = this.Name;
			target.Password = this.Password;
			target.EMail = this.EMail;
			target.Vorname = this.Vorname;
			target.Nachname = this.Nachname;
			target.LastLogin = this.LastLogin;
			target.CreationTime = this.CreationTime;
		}