2017-12-08 1 views
1

모바일 앱에서 등록 할 때 Wcf 서비스와 Xamarin.forms 모바일 애플리케이션이 있습니다. 사용자가 이메일로 이동할 때 웹 서비스에서 사용자에게 이메일 확인을 보내주기를 원합니다. 사용자 계정이 활성화 될 링크를 클릭합니다.이메일 확인 확인

나는 확인 링크에 사용자 ID가 있고 인증 기능과 사용자 ID가 뒤에 오는 서비스 URL을 제공하는 유일한 해결책이 있습니다.

링크에서 wcf 링크를주고 싶지 않으므로 더 안전한 방법이 있습니까?

private void SendEmailConfirmation(String EmailId,string UserId) 
     { 
      MailMessage msg = new MailMessage(); 
      SmtpClient smtp = new SmtpClient(); 
      string emailId = EmailId; 
      msg.From = new MailAddress("[email protected]");   
      msg.To.Add(emailId); 
      msg.Subject = "Confirmation email for account activation"; 
      //For testing replace the local host path with your lost host path and while making online replace with your website domain name 
      //string ActivationUrl = "http://localhost:8665/FetchUserId(emailId) & "&EmailId=" & emailId); 
      msg.Body ="Thanks for showing interest and registring in <a href='http://www.activationlink.com'> webservice.com<a> " + 
        " Please Thanks!"; 
      msg.IsBodyHtml = true; 
      smtp.Credentials = new NetworkCredential("[email protected]", "mypassword"); 
      smtp.Port = 587; 
      smtp.Host = "smtp.gmail.com"; 
      smtp.EnableSsl = true; 
      //NetworkCredential Credentials = new NetworkCredential("[email protected]", "[email protected]"); 
      //smtp.UseDefaultCredentials = false; 
      smtp.Send(msg); 
     } 
+0

무엇이 당신의 질문입니까? 그것은 사용자의 신원인가? 확인 링크? – Daniel

답변

-2
using System.Linq; 
using System.Net; 
using System.Net.Mail; 

당신은 위의 네임 스페이스를 가져와야합니다.

+0

우편 발송은 OP의 문제가 아닙니다. –

1

비 감각적 인 코드 (토큰, 해시, GUID 등)를 생성하고 이것을 사용자 데이터와 날짜 제한에 연결하여 해당 링크를 활성화 할 수 있습니다 (예 : 24 시간).

그런 다음 사용자가 토큰과 함께이 링크를 클릭하면 토큰이 여전히 유효한지 확인하고 사용자 계정을 사용할 수 있는지 확인합니다.

+0

예, 좋은 생각입니다. 시도해 보겠습니다. @Diego 감사합니다. – Immortal