Exemple #1
0
        public async Task <IActionResult> DeleteChannel(DeleteChannelAddressModel model)
        {
            var appid   = _tokenManager.ValidateAccessToken(model.AccessToken);
            var channel = await _dbContext.Channels.FindAsync(model);

            if (channel.AppId != appid)
            {
                return(Json(new AiurProtocol {
                    Code = ErrorType.Unauthorized, Message = "The channel you try to delete is not your app's channel!"
                }));
            }
            _dbContext.Channels.Remove(channel);
            await _dbContext.SaveChangesAsync();

            return(Json(new AiurProtocol {
                Code = ErrorType.Success, Message = "Successfully deleted your channel!"
            }));
        }
Exemple #2
0
        public async Task <IActionResult> DeleteChannel([FromForm] DeleteChannelAddressModel model)
        {
            var app = await ApiService.ValidateAccessTokenAsync(model.AccessToken);

            var channel = await _dbContext.Channels.FindAsync(model);

            if (channel.AppId != app.AppId)
            {
                return(Json(new AiurProtocal {
                    code = ErrorType.Unauthorized, message = "The channel you try to delete is not your app's channel!"
                }));
            }
            _dbContext.Channels.Remove(channel);
            await _dbContext.SaveChangesAsync();

            return(Json(new AiurProtocal {
                code = ErrorType.Success, message = "Successfully deleted your channel!"
            }));
        }
Exemple #3
0
        public async Task <IActionResult> DeleteChannel([FromForm] DeleteChannelAddressModel model)
        {
            var token = await _dbContext.AccessTokens.Include(t => t.ApplyApp).SingleOrDefaultAsync(t => t.Value == model.AccessToken);

            if (token == null || token.ApplyApp == null)
            {
                return(this.Protocol(ErrorType.Unauthorized, "Invalid accesstoken!"));
            }
            var channel = await _dbContext.Channels.FindAsync(model);

            if (channel.AppId != token.ApplyAppId)
            {
                this.Protocol(ErrorType.Unauthorized, "The channel you try to delete is not your app's channel!");
            }
            _dbContext.Channels.Remove(channel);
            await _dbContext.SaveChangesAsync();

            return(this.Protocol(ErrorType.Success, "Successfully deleted your channel!"));
        }