FOSUserBundle getRoles admin

时间:2015-10-08 12:46:10

标签: symfony fosuserbundle

我在我的User类中添加了一个类似的字段 public class EmailDAL { internal string SMTP = ConfigurationManager.AppSettings["smtpServer"]; internal string MailAddress = ConfigurationManager.AppSettings["smtpUser"]; internal string Pwd = ConfigurationManager.AppSettings["smtpPass"]; internal int Port = Convert.ToInt16(ConfigurationManager.AppSettings["smtpPort"]); internal bool ssl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSsl"]); public string SendEmail(string toMail, string mailSubject, string Message) { SmtpClient SmtpServer = new SmtpClient(SMTP); var mail = new MailMessage(); mail.From = new MailAddress(MailAddress); mail.To.Add(toMail); mail.Subject = mailSubject; mail.IsBodyHtml = true; mail.Body = "<p style='line-height: 30px;'>" + Message + "</p>"; SmtpServer.Port = Port; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential(MailAddress, Pwd); SmtpServer.EnableSsl = ssl; try { SmtpServer.Send(mail); return "Send Sucessfully"; } catch (Exception ex) { return ex.Message.ToString(); } } }
我需要覆盖 UserInterface-&gt; getRoles()方法并返回我拥有的所有角色。 /** * @ORM\Column(type="boolean", nullable=false) */ protected $isOp;Role,它实现了FOS提供的Entity。 当我拨打RoleInterface时,在我的任何模板内部,如果用户的组被标记为is_granted('ROLE_DOUGH')(isOp字段),我需要立即获得。

0 个答案:

没有答案