Ejemplo n.º 1
0
        /* Delete User */
        public async Task<OpObject> DeleteUser(String SessionId, String eMail, String Password)
        {
            /* Create return object */
            IsolatedContext IsoContext = new IsolatedContext(SessionId);

            /* Execute function */
            return await Execute(new Func<Task>(async () =>
            {
                /* We need user repository for this */
                using (UserRepository UserRepo = new UserRepository())
                {
                    /* Does password and email match? */
                    IsoContext.RetObj = await UserRepo.TestPassword(eMail, Password);

                    /* Sanity */
                    if (IsoContext.RetObj.Code != StatusCode.Ok)
                        return;

                    /* Try to delete */
                    IsoContext.RetObj = await UserRepo.Delete(IsoContext.uGuid);
                }
            }), IsoContext);
        }
Ejemplo n.º 2
0
        /* Login */
        public async Task<OpObject> Login(String eMail, String Password)
        {
            /* Create return object */
            IsolatedContext IsoContext = new IsolatedContext();

            /* Execute function */
            return await Execute(new Func<Task>(async () =>
            {
                using (UserRepository UserRepo = new UserRepository())
                {
                    /* Does password and email match? */
                    IsoContext.RetObj = await UserRepo.TestPassword(eMail, Password);

                    /* Return ConfCode */
                    using (MaintienceRepository MainRepo = new MaintienceRepository())
                    {
                        /* Very Sanity */
                        if (IsoContext.RetObj.Code == StatusCode.UserNotConfirmed)
                        {
                            /* Lookup */
                            String ConfCode =
                                await MainRepo.GetCode(CodeType.Confirmation, (String)IsoContext.RetObj.Data);

                            /* Sanity */
                            if (ConfCode == "0")
                            {
                                ConfCode = await MainRepo.CreateCode(CodeType.Confirmation,
                                    (String)IsoContext.RetObj.Data);
                            }

                            /* Set */
                            IsoContext.RetObj.Data = ConfCode;
                        }

                        /* Sanity */
                        if (IsoContext.RetObj.Code != StatusCode.Ok)
                            return;

                        /* Are we logged in already? */
                        String SessionId = await MainRepo.HasSession((String)IsoContext.RetObj.Data);

                        if (SessionId != "0")
                        {
                            IsoContext.RetObj = new OpObject(StatusCode.Ok, SessionId);
                            return;
                        }

                        /* No, create a session */
                        IsoContext.RetObj.Data = await MainRepo.CreateSessionId((String)IsoContext.RetObj.Data);
                    }
                }
            }), IsoContext);
        }