Example #1
0
        public override async Task <Reply> Logout(Empty request, ServerCallContext context)
        {
            var replay = new Reply();
            await _loginUserService.ClearUser(context.GetHttpContext());

            return(replay);
        }
Example #2
0
        public override async Task <Reply> Delete(StringId request, ServerCallContext context)
        {
            var reply = new Reply();
            var user  = await _userService.GetUser(context.GetHttpContext());

            if (user == null)
            {
                reply.Error = Error.NeedLogin;
                return(reply);
            }

            if (!user.HasWritePermission())
            {
                reply.Error = Error.NoPermission;
                return(reply);
            }

            await _userService.ClearUser(request.Id);

            var existed = await _service.All().FirstOrDefaultAsync(u => u.Id == request.Id);

            if (existed == null)
            {
                reply.Error = Error.NoSuchEntity;
                return(reply);
            }

            await _service.Delete(existed);

            return(reply);
        }