-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pessoal agora esta 100% funcionando
- Loading branch information
Showing
41 changed files
with
475 additions
and
73 deletions.
There are no files selected for viewing
Binary file not shown.
158 changes: 158 additions & 0 deletions
158
IdezJobsWeb/IdezJobsWeb/Areas/Administrative/Controllers/AccountController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Security; | ||
using IdezJobsWeb.Models; | ||
|
||
namespace IdezJobsWeb.Areas.Administrative.Controllers | ||
{ | ||
[Authorize(Roles = "Administrador")] | ||
public class AccountController : Controller | ||
{ | ||
// | ||
// GET: /Administrative/Account/ | ||
|
||
public ActionResult Index( ) | ||
{ | ||
return View( ); | ||
} | ||
|
||
public ActionResult LogOff( ) | ||
{ | ||
FormsAuthentication.SignOut( ); | ||
|
||
return RedirectToAction("Index", "Home"); | ||
} | ||
|
||
|
||
|
||
public ActionResult Register( ) | ||
{ | ||
return View( ); | ||
} | ||
|
||
|
||
|
||
[HttpPost] | ||
public ActionResult Register(RegisterUserCollege model) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
|
||
MembershipCreateStatus createStatus; | ||
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); | ||
|
||
if (createStatus == MembershipCreateStatus.Success) | ||
{ | ||
FormsAuthentication.SetAuthCookie(model.UserName, false); | ||
return RedirectToAction("Index", "Home"); | ||
} | ||
else | ||
{ | ||
ModelState.AddModelError("", ErrorCodeToString(createStatus)); | ||
} | ||
} | ||
|
||
|
||
return View(model); | ||
} | ||
|
||
|
||
|
||
[Authorize] | ||
public ActionResult ChangePassword( ) | ||
{ | ||
return View( ); | ||
} | ||
|
||
|
||
|
||
[Authorize] | ||
[HttpPost] | ||
public ActionResult ChangePassword(ChangePasswordModel model) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
|
||
|
||
bool changePasswordSucceeded; | ||
try | ||
{ | ||
MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true); | ||
changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword); | ||
} | ||
catch (Exception) | ||
{ | ||
changePasswordSucceeded = false; | ||
} | ||
|
||
if (changePasswordSucceeded) | ||
{ | ||
return RedirectToAction("ChangePasswordSuccess"); | ||
} | ||
else | ||
{ | ||
ModelState.AddModelError("", "A senha atual está incorreta ou a nova senha é inválida."); | ||
} | ||
} | ||
|
||
|
||
return View(model); | ||
} | ||
|
||
|
||
|
||
public ActionResult ChangePasswordSuccess( ) | ||
{ | ||
return View( ); | ||
} | ||
|
||
#region Status Codes | ||
private static string ErrorCodeToString(MembershipCreateStatus createStatus) | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkID=177550 for | ||
// a full list of status codes. | ||
switch (createStatus) | ||
{ | ||
case MembershipCreateStatus.DuplicateUserName: | ||
return "Nome de usuário já existe. Digite um nome de usuário diferente."; | ||
|
||
case MembershipCreateStatus.DuplicateEmail: | ||
return "Um nome de usuário para esse endereço de e-mail já existe. Digite um endereço de e-mail diferente."; | ||
|
||
case MembershipCreateStatus.InvalidPassword: | ||
return "A senha fornecida é inválida. Por favor, insira um valor de senha válida."; | ||
|
||
case MembershipCreateStatus.InvalidEmail: | ||
return "O endereço de e-mail fornecido é inválido. Por favor, verifique o valor e tente novamente."; | ||
|
||
case MembershipCreateStatus.InvalidAnswer: | ||
return "A resposta de recuperação de senha fornecida é inválida. Por favor, verifique o valor e tente novamente."; | ||
|
||
case MembershipCreateStatus.InvalidQuestion: | ||
return "A questão de recuperação de senha fornecida é inválida. Por favor, verifique o valor e tente novamente."; | ||
|
||
case MembershipCreateStatus.InvalidUserName: | ||
return "O nome de usuário fornecido é inválido. Por favor, verifique o valor e tente novamente."; | ||
|
||
case MembershipCreateStatus.ProviderError: | ||
return "O provedor de autenticação retornou um erro. Por favor, verifique a sua entrada e tente novamente. Se o problema persistir, contate o administrador do sistema."; | ||
|
||
case MembershipCreateStatus.UserRejected: | ||
return "O pedido de criação do usuário foi cancelado. Por favor, verifique a sua entrada e tente novamente. Se o problema persistir, contate o administrador do sistema."; | ||
|
||
default: | ||
return "Ocorreu um erro desconhecido. Por favor, verifique a sua entrada e tente novamente. Se o problema persistir, contate o administrador do sistema."; | ||
} | ||
} | ||
#endregion | ||
|
||
public ActionResult undefined( ) | ||
{ | ||
return View( ); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
IdezJobsWeb/IdezJobsWeb/Areas/Administrative/Views/Account/ChangePassword.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@model IdezJobsWeb.Models.ChangePasswordModel | ||
|
||
@{ | ||
ViewBag.Title = "Trocar Senha"; | ||
Layout = "~/Areas/Administrative/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>Trocar Senha</h2> | ||
<p> | ||
Use este formulário para alterar sua senha. | ||
</p> | ||
<p> | ||
Novas senhas requerem no mínimo de @Membership.MinRequiredPasswordLength caracteres. | ||
</p> | ||
|
||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> | ||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> | ||
|
||
@using (Html.BeginForm()) { | ||
@Html.ValidationSummary(true, "Não foi possível alterar a senha, por favor verifique os campos e tente novamente.") | ||
<div> | ||
<fieldset> | ||
<legend>Informações de sua conta:</legend> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.OldPassword,"Senha Atual:") | ||
</div> | ||
<div class="editor-field"> | ||
@Html.PasswordFor(m => m.OldPassword) | ||
@Html.ValidationMessageFor(m => m.OldPassword) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.NewPassword,"Nova Senha:") | ||
</div> | ||
<div class="editor-field"> | ||
@Html.PasswordFor(m => m.NewPassword) | ||
@Html.ValidationMessageFor(m => m.NewPassword) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.ConfirmPassword,"Confirme Nova Senha:") | ||
</div> | ||
<div class="editor-field"> | ||
@Html.PasswordFor(m => m.ConfirmPassword) | ||
@Html.ValidationMessageFor(m => m.ConfirmPassword) | ||
</div> | ||
|
||
<p> | ||
<input type="submit" value="Salvar" id="ButtonAlterarSenha" /> | ||
</p> | ||
</fieldset> | ||
</div> | ||
} |
12 changes: 12 additions & 0 deletions
12
IdezJobsWeb/IdezJobsWeb/Areas/Administrative/Views/Account/ChangePasswordSuccess.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
@{ | ||
ViewBag.Title = "Troca Senha Sucesso"; | ||
Layout = "~/Areas/Administrative/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>Alteração de Senha</h2> | ||
<p> | ||
Parabéns, sua senha foi alterada com sucesso.. | ||
</p> | ||
<br/> | ||
@Html.ActionLink("Index","Index") |
64 changes: 64 additions & 0 deletions
64
IdezJobsWeb/IdezJobsWeb/Areas/Administrative/Views/Account/Register.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@model IdezJobsWeb.Models.RegisterUserCollege | ||
|
||
@{ | ||
ViewBag.Title = "Register"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
|
||
|
||
<h2>Criar uma nova conta</h2> | ||
<p> | ||
Use o formulário abaixo para criar uma nova conta | ||
</p> | ||
<p> | ||
Atenção a senha deve ter no mínimo @Membership.MinRequiredPasswordLength caracteres. | ||
</p> | ||
|
||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> | ||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> | ||
|
||
@using (Html.BeginForm()) { | ||
@Html.ValidationSummary(true, "Por favor, verifique se não tem algo errado pois não consegui criar sua conta.") | ||
<div> | ||
<fieldset> | ||
<legend>Account Information</legend> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.UserName) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.TextBoxFor(m => m.UserName) | ||
@Html.ValidationMessageFor(m => m.UserName) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.Email) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.TextBoxFor(m => m.Email) | ||
@Html.ValidationMessageFor(m => m.Email) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.Password) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.PasswordFor(m => m.Password) | ||
@Html.ValidationMessageFor(m => m.Password) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(m => m.ConfirmPassword) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.PasswordFor(m => m.ConfirmPassword) | ||
@Html.ValidationMessageFor(m => m.ConfirmPassword) | ||
</div> | ||
|
||
<p> | ||
<input type="submit" value="Salvar" /> | ||
</p> | ||
</fieldset> | ||
</div> | ||
} |
Oops, something went wrong.