Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Restrict user actions by session details using a validator


One common pattern for web applications today is to encourage or require new users to register for an account before they can use certain features. One way to simplify authentication for application users is to integrate with a social media platform. Certain areas of your application might be available to anonymous and registered users, while other areas might require authentication. In this situation, you would want to restrict actions that require this external service. In this recipe, we will look at creating a validator that checks certain session properties of the user and returns a validation response if a predefined rule is not met.

Getting ready

If you are using a non-express version of Visual Studio, you can start this recipe using ServiceStackVS and create a new project based on any of the ServiceStack templates available. If you are using an express version of Visual Studio, please follow Creating a ServiceStack solution...