view SilverlightExampleApp/SilverlightExampleApp.Web/Services/AuthenticationService.svc.cs @ 70:39ba36cc82c5

not sure about these...
author Steven Hollidge <stevenhollidge@hotmail.com>
date Mon, 23 Apr 2012 11:06:29 +0100
parents 502f5f365649
children
line wrap: on
line source

using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Web.Security;

namespace SilverlightExampleApp.Web.Services
{
    [ServiceContract(Namespace = "")]
    [SilverlightFaultBehavior]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class AuthenticationService
    {
        [OperationContract]
        public bool Authenticate(string username, string password)
        {
            if (ValidateLogin(username, password))
            {
                FormsAuthentication.SetAuthCookie(username, false);
                return true;
            }
            return false;
        }

        [OperationContract]
        public bool LogOut()
        {
            FormsAuthentication.SignOut();   
            return true;
        }

        public bool ValidateLogin(string username, string password)
        {
            return username == "stevenh" && password == "password";
        }
    }
}