Beispiel #1
0
		private void detach_access_tokens(access_tokens entity)
		{
			this.SendPropertyChanging();
			entity.accounts = null;
		}
Beispiel #2
0
 partial void Deleteaccess_tokens(access_tokens instance);
Beispiel #3
0
 partial void Insertaccess_tokens(access_tokens instance);
Beispiel #4
0
 partial void Updateaccess_tokens(access_tokens instance);
Beispiel #5
0
            /*            public static string GetAccessToken( string email, string password, string requester)
                        {
                            var acc = context.accounts.FirstOrDefault(ac =>  ac.email == email && ac.password == password);
                            if (acc != null)
                            {
                                int dat = Time.UNIXNow();
                                var at = new access_tokens()
                                {
                                    owner = acc.ID,
                                    date = dat,
                                    requester = requester,
                                    token = CreateMD5Hash(acc.email + dat.ToString())
                                };
                                context.access_tokens.InsertOnSubmit(at);
                                try
                                {
                                    Save();
                                    return at.token;
                                }
                                catch
                                {
                                    return "error";
                                }
                            }
                            return "denied";
                        }
                       */
            public static string GetAccessToken(Models.LoginView login)
            {
                accounts acc;

                acc = context.accounts.FirstOrDefault(ac => ac.email == login.email && ac.password == login.password);

                if (acc != null)
                {
                    int dat = Time.UNIXNow();
                    var at = new access_tokens()
                    {
                        owner = acc.ID,
                        date = dat,
                        requester = login.requester,
                        token = CreateMD5Hash(acc.email + dat.ToString())
                    };
                    context.access_tokens.InsertOnSubmit(at);
                    try
                    {
                        if (Save())
                            return at.token;
                    }
                    catch
                    {
                        return "error";
                    }
                }
                return "denied";
            }